PDA

View Full Version : Grid panel displays all the value in 1 line



marxan
27 Sep 2011, 3:33 AM
Hello,

I have generated the following Json through a coldfusion function. It contains 2 records but when I display it in my grid, instead of creating 2 lines, it puts the 2 values in a line. Does anyone knows if I can configure my store to read this JSON properly?

Thanks in advance.

The Json:

{"ROWCOUNT":2,
"COLUMNS":["MOD_ID","WHO"],
"DATA":{"MOD_ID":[1,2],"WHO":["AD","AD"]}}

The store:

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
//fields: ['mod_id', 'who'],
proxy: {
type: 'ajax',
url: 'app/store/getData.cfm',
reader: {
type: 'json',
root: 'DATA'
}
},
autoLoad: true
});



The grid:

Ext.define('AM.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.userlist',

title : 'All Users',
store: 'Users',
columns: [
{header: 'Mod ID', dataIndex: 'MOD_ID', flex: 1},
{header: 'Who', dataIndex: 'WHO', flex: 1}
]
});

skirtle
27 Sep 2011, 3:57 AM
You'd need a custom reader to cope with that response format. This sort of thing has been requested before, if you search you may be able to find other threads that discuss how to do it. Here's one similar thread but I'm pretty sure I've seen cases that are even closer to the one you describe:

http://www.sencha.com/forum/showthread.php?143721

A more normal format would be something like this:


{
"ROWCOUNT":2,
"COLUMNS":["MOD_ID","WHO"],
"DATA": [
{"MOD_ID": 1, "WHO": "AD"},
{"MOD_ID": 2, "WHO": "AD"}
]
}