PDA

View Full Version : Grid is not displaying for JSON Reader



sridhar.boganathan
2 Apr 2012, 5:08 AM
Hi All,

I am using store, model and JSON reader for grid. And also, I am using gridObj.reconfigure(storeObj). Since, mine grid is dynamic one. My server url is gettng hit and got the response also. Still, data is not displaying in the grid.

var gridObj = Ext.create('Ext.data.Store', {
autoLoad: true,
model: modelName,
proxy: {
type: 'ajax',
url : 'http://serverurl/getData.json',
reader: {
type: 'json',
root: 'data',
record: 'record'
}
}
});
gridObj.reconfigure(gridObj);

I have been loggin gridObj.count() to debug. It always gives me '0 (ZERO)'.

Please let me know what I am doing wrong
-Sridhar

skirtle
2 Apr 2012, 6:24 AM
In the code you've posted, gridObj appears to be both your store and your grid. It can't be both.

You'll need to post your model and a sample of your JSON for us to diagnose where your problem lies. If it's the same JSON that you posted on your other thread then you'll need to change your root to 'data.record' and get rid of the record config option.

sridhar.boganathan
2 Apr 2012, 9:26 PM
In the code you've posted, gridObj appears to be both your store and your grid. It can't be both.

You'll need to post your model and a sample of your JSON for us to diagnose where your problem lies. If it's the same JSON that you posted on your other thread then you'll need to change your root to 'data.record' and get rid of the record config option.

Thanks, when I pasted the code to this post I did mistake. In my code, this line is correct only (gridObj.reconfigure(storeObj)) ;. I have tried with 'data.record'. Same error:(.

Here is my model

Ext.define(modelName,{
extend: 'Ext.data.Model',
fields: [
{name: "id", mapping :"id"},
{name: "name", mapping: "name"}
]
});

-Sridhar.

sridhar.boganathan
3 Apr 2012, 12:28 AM
In the code you've posted, gridObj appears to be both your store and your grid. It can't be both.

You'll need to post your model and a sample of your JSON for us to diagnose where your problem lies. If it's the same JSON that you posted on your other thread then you'll need to change your root to 'data.record' and get rid of the record config option.

Thanks, it is working now.

-Sridhar