PDA

View Full Version : having trouble connecting my store to paging grid



piston
1 Mar 2011, 7:50 AM
I had a grid working fine with an XMLstore and reader. Since no one seems to be using XML anymore I decided to try a Json store. I have a php file making me a beautiful json file - that's not the problem. The problem must lie somewhere in this code which I added to my grid js file:


var store = new Ext.data.JsonStore({
url: 'http://site.com/extjs/examples/grid/contact_echo2.php',
root: 'contacts',
autoDestroy: true,
idProperty: 'id',
totalProperty: 'total',
remoteSort: true,
fields:[
{name: 'full_name'},
{name: 'email'},
{name: 'id'},
{name: 'fax'},
{name: 'type'},
{name: 'active', type: 'float'},
{name: 'method'},
{name: 'address1'},
{name: 'address2'},
{name: 'city'},
{name: 'state'},
{name: 'zip'},
{name: 'notes'},
{name: 'hash'}
]
});
Do you see anything in there which would prevent my grid from populating with my store? My Json store is formatted correctly with this as the start:

{ total:'16', contacts: [{id:'11',hash:'396a...
I can't figure it out. Everything looks perfect to me. I went into Firebug and the php file is indeed loading fine on the page - just not into the grid. I didn't touch the rest of the code in the grid file, but maybe I should if I changed the store? I didn't rename it or anything. I don't need a reader with Json, right?

swarm
1 Mar 2011, 1:20 PM
Your JSON doesn't look valid.

Try pasting it into www.jsonlint.com to see if it's valid.

piston
2 Mar 2011, 6:21 AM
you were right - the json was coming up but something in it was not quite right. I went one item at a time until I got it all correct. thanks