Hi, I'm trying to load data to my grid panel which resides in php using JsonStore object. But the problem is JsonStore is not getting data from php only. Can anyone tell me where i've gone wrong. Is my php file is proper or not? I'm very new to both php and extjs. please help me out.
i'm uploading the both .js and .php files. please help me out.
test.js file:
test.php file:
i'm uploading the both .js and .php files. please help me out.
test.js file:
Code:
Ext.onReady(function(){ alert("inside onReady"); Ext.QuickTips.init(); var employee = Ext.data.Record.create([ {name:'firstname'}, {name:'lastname'}]); //var myReader = new Ext.data.JsonReader({ //root:"root" //},employee); var store = new Ext.data.JsonStore({ id:'ID' ,root:'root' ,totalProperty:'totalCount' ,url:'test.php' ,autoLoad:true //,reader:myReader //,baseParams:{mod:'data',act:'getAllData'} ,fields:[ {name:'firstname', type:'string'} ,{name:'lastname', type:'string'} ] }); alert("Before Displaying"); var n = store.getTotalCount(); alert(n); var myPanel = new Ext.grid.GridPanel({ store: store ,columns:[{ dataIndex:'firstname' ,header:'First Name' ,width:145 ,sortable:true },{ dataIndex:'lastname' ,header:'Last Name' ,width:145 ,sortable:true } ], viewConfig: { autoFill: true, forceFit: true }, listeners: { render: function(grid) { grid.store.load(); } } }); //store.load({params:{firstname:'Vibha',lastname:'Bhagath'}}); var myWindow = new Ext.Window({ width:300, height:300, layout:'fit', closable:false, resizable:false, items:[myPanel] }); myWindow.show(); });
Code:
<?php session_start(); $o = array( "success" => true, "records" => array( {"firstname" => "Vibha" , "lastname" => "Bhagath"},{"firstname" => "Santu" , "lastname" => "Sapi"},{"firstname" => "Shivoo" , "lastname" => "Koteshwar"}) ); $_SESSION["err"] = isset($_SESSION["err"]) ? !$_SESSION["err"] : true; header("Content-Type: application/json"); print(json_encode($o)); ?>
Comment