PDA

View Full Version : Ext.gird.GridPanel using a JsonStore



waschtl
13 Sep 2010, 6:32 AM
Hi Forum, im trying to send data from my server to a JsonStore and display it in a GridPanel.
My code looks like this:



var store = new Ext.data.JsonStore({
root: 'computers',
idProperty: 'serial_nr',
proxy: new Ext.data.HttpProxy({
url: 'ajax_overview_engines_computer',
method: 'GET'
}),
idProperty: 'serial_nr',
fields: ['serial_nr', 'instalation_date', 'removal_date']

})

var grid = new Ext.grid.GridPanel({
store: store,
autoHeight: true,
columns: [{
header: 'SerialNr',
width: 130,
dataIndex: 'serial_nr',
sortable: true
}, {
header: 'Enbaudatum',
dataIndex: 'instalation_date',
width: 130,
sortable: true
}, {
header: 'Ausbaudatum',
dataIndex: 'removal_date',
width: 130,
sortable: true
}]
})
when i log the received data with firebug a received string looks like this:


{"computers": [{"instalation_date": "09.09.2010", "serial_nr": "12388", "removal_date": "09.09.2010"}, {"instalation_date": "09.09.2010", "serial_nr": "12388", "removal_date": "09.09.2010"}, {"instalation_date": "09.09.2010", "serial_nr": "12388", "removal_date": "09.09.2010"}, {"instalation_date": "12.09.2010", "serial_nr": "12388", "removal_date": 0}]}
so far the Json format looks like the suggested format in the documentation (http://dev.sencha.com/deploy/dev/docs/output/Ext.data.JsonStore.html). But when I reload the data from the server only the last dataset in my Json Object is displayed in my grid and stored in the JsonStore. All the other Datasets are ignored.
I guess I'm missing something.

13 Sep 2010, 6:44 AM
Your data. The ID properties are exactly the same on each record.

http://tdg-i.com/img/screencasts/2010-09-13_1043.png

waschtl
13 Sep 2010, 7:06 AM
yes, you are right. I also erased that line earlier this day but had the same Problem. But if you look at my code the line with the idProperty is double. Damn so easy - everything works
thanks a lot jgarcia this took me about 2 hours.