alfiewong
28 Feb 2007, 5:24 AM
Hello,
I was wondering if somebody could help me because I'm not sure why my data isn't displaying in my grid. Here are the code snipits:
function getDataCallback(data)
{
var guests = Ext.data.Record.create([
{name: 'guest', mapping: 'guestName'},
{name: 'attendingReception', mapping: 'comingToReception'},
{name: 'attendingCeremony', mapping: 'comingToCeremony'}
]);
// create reader that reads into Topic records
var reader = new Ext.data.JsonReader({
root: 'guests',
id: 'guestName'
}, guests);
// create the Data Store
var ds = new Ext.data.Store({
// load using script tags for cross domain
proxy: new Ext.data.MemoryProxy(data),
reader: reader,
remoteSort: true
});
ds.setDefaultSort('guest', 'desc');
var cm = new Ext.grid.ColumnModel([
{
header:'Guest',
dataIndex:'guest'
},
{
header:'Attending Ceremony',
dataIndex:'attendingCeremony',
hidden:!isInvitedToCeremony
},
{
header:'Attending Reception',
dataIndex:'attendingReception',
hidden:!isInvitedToReception
}]);
// create the editor grid
var grid = new Ext.grid.Grid('container', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:true
});
// render it
ds.load();
grid.render();
}
here is how the JSON data is returned:
{"guests":[{"comingToReception":false,"guestName":"Lily Tran","comingToCeremony":false},{"comingToReception":false,"guestName":"Alfred Wong","comingToCeremony":false}]}
If there is something wrong with the setup of the grid please let me know but I think it looks right. I was wondering if I need to have some JSON library on the client side to use the JsonReader?
I was debugging through the code using FireBug and the part that keeps on dying is in the JsonReader code were it tries to get set the root object by using eval("o." + s.root).
I'm not sure if I'm doing something wrong or need something if somebody could help me out that would be great because I've spent way too long on trying to figure out what I'm doing wrong. :D
Thanks,
Alfred
I was wondering if somebody could help me because I'm not sure why my data isn't displaying in my grid. Here are the code snipits:
function getDataCallback(data)
{
var guests = Ext.data.Record.create([
{name: 'guest', mapping: 'guestName'},
{name: 'attendingReception', mapping: 'comingToReception'},
{name: 'attendingCeremony', mapping: 'comingToCeremony'}
]);
// create reader that reads into Topic records
var reader = new Ext.data.JsonReader({
root: 'guests',
id: 'guestName'
}, guests);
// create the Data Store
var ds = new Ext.data.Store({
// load using script tags for cross domain
proxy: new Ext.data.MemoryProxy(data),
reader: reader,
remoteSort: true
});
ds.setDefaultSort('guest', 'desc');
var cm = new Ext.grid.ColumnModel([
{
header:'Guest',
dataIndex:'guest'
},
{
header:'Attending Ceremony',
dataIndex:'attendingCeremony',
hidden:!isInvitedToCeremony
},
{
header:'Attending Reception',
dataIndex:'attendingReception',
hidden:!isInvitedToReception
}]);
// create the editor grid
var grid = new Ext.grid.Grid('container', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:true
});
// render it
ds.load();
grid.render();
}
here is how the JSON data is returned:
{"guests":[{"comingToReception":false,"guestName":"Lily Tran","comingToCeremony":false},{"comingToReception":false,"guestName":"Alfred Wong","comingToCeremony":false}]}
If there is something wrong with the setup of the grid please let me know but I think it looks right. I was wondering if I need to have some JSON library on the client side to use the JsonReader?
I was debugging through the code using FireBug and the part that keeps on dying is in the JsonReader code were it tries to get set the root object by using eval("o." + s.root).
I'm not sure if I'm doing something wrong or need something if somebody could help me out that would be great because I've spent way too long on trying to figure out what I'm doing wrong. :D
Thanks,
Alfred