PDA

View Full Version : Grouping Grid Not Displaying



scblue
4 Mar 2010, 1:48 AM
Hi,

I am having trouble with grouping the data in my grid.
I was using a JsonStore but then changed to GroupingStore for the purpose.
What I want to do is to let the users pick the grouping from the menu in the header.

Here are some snippets of my code:




function creategrid(t){

stores[t] = new Ext.data.GroupingStore({
url: 'database.php?action=listing&type='+ t ,
reader: new Ext.data.JsonReader(),
groupField: 'id',
autoLoad: true
});

colModel = new Ext.grid.ColumnModel({
defaults: {
align: 'left',
resizable: false,
sortable: false,
width: 200
}
});

grids[t] = new Ext.grid.GridPanel({
..
..
..
view: new Ext.grid.GroupingView({
forceFit:true
})
});
And here's my metadata returned from Json.


{
"success":true,
"total":12,
"metaData": {
"root":"rows",
"fields" : ["id","wname"],
"sortInfo":{
"field": "id",
"direction": "ASC"
},
"totalProperty": "total",
"remoteSort": true,
"colModel": [{"header":"ID", "dataIndex":"id", "width":350},{"header":"WNAME", "dataIndex":"wname", "width":350},]
},
"rows":[{"id":"28","wname":"ddd"},{"id":"27","wname":"fccc"},{"id":"21","wname":"ggg"},{"id":"22","wname":"t"},{"id":"16","wname":"rrrrr2121"},{"id":"26","wname":"d"},{"id":"15","wname":"newnewaaa"},{"id":"9","wname":"123123"},{"id":"24","wname":"c"},{"id":"25","wname":"r"}]
}

I can't see where the error is at.

Error returned is h is undefined.

My grid displays ok when I was only using JsonStore.

Thanks for your help!

fay
4 Mar 2010, 1:58 AM
For development/debugging purposes use ext-all-debug.js - you'll get more explanatory error messages.

From looking at your metaData, could it be the errant comma at the end of this line?


}{"header":"WNAME", "dataIndex":"wname", "width":350},]

If in doubt always run your JSON through JSONLint (http://www.jsonlint.com).

scblue
4 Mar 2010, 5:45 PM
For development/debugging purposes use ext-all-debug.js - you'll get more explanatory error messages.

From looking at your metaData, could it be the errant comma at the end of this line?


}{"header":"WNAME", "dataIndex":"wname", "width":350},]If in doubt always run your JSON through JSONLint (http://www.jsonlint.com).

Thanks for taking the time to reply. :)

I don't think that's the problem because the same Json works when I was using JsonStore.
It was when I changed it to GroupingStore that it didn't work.

I am just wondering if there's a problem with my code that I didn't manage to catch.

Nevertheless, I'll recheck my Json and see if it makes a diff.

scblue
4 Mar 2010, 6:24 PM
Now it shows

'cfg is undefined'.

I've search the forums and the problem was not including group field in the columns.

But I did:


stores[t] = new Ext.data.GroupingStore({
url: 'database.php?action=listing&type='+ t ,
reader: new Ext.data.JsonReader(),
groupField: 'id',
autoLoad: true
});

Json:
"colModel": [{"header":"ID", "dataIndex":"id", "width":350}
But my Json was returned by metadata.
Does that in anyway cause the error?

scblue
5 Mar 2010, 1:32 AM
I'm out of ideas. I've tried practically everything, compared my codes with other examples.
I can;t see any significant difference.
Can someone help?

Thanks in advance!