PDA

View Full Version : jsonStore loading fine, Grid isn't



OSUWebDev_TBell
9 Jun 2010, 12:03 PM
Hello All-

I'm in the beginning stages of learning how to develop with extJS and have come across a problem. The code posted below is giving me the data I want (as seen in firebug), but it is not displaying in my Grid. It's a simple little application, but I can't seem to find the info I need to fix this. Perhaps just another set of eyes will work.

Thanks


Ext.onReady(function(){


var logStore = new Ext.data.SimpleStore({
autoLoad: true,
url: 'inc/config.php?list=messages',
reader: new Ext.data.JsonReader({
root: 'messages',
fields: ['Message'],
})
});

var logGrid = new Ext.grid.GridPanel({
anchor: '100% 100%',
region: 'center',
store: logStore,
listeners:{
activate: function(){
logStore.reload();
}
},
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 1000,
sortable: true},
columns:[
{id: 'Message', header: 'Message', dataIndex: 'Message'},
]
})
});
var centerPanel = new Ext.Panel({
layout: 'anchor',
region: 'center',
title: 'DHCP Log',
icon: 'inc/images/icons/email.png',
items: [logGrid],
});

var mainViewport = new Ext.Viewport({
layout: 'border',
items: [centerPanel],

});




});

darthwes
9 Jun 2010, 1:48 PM
Put your code in the code tags please. A JsonStore is what you want. JsonStores _are_ readers, use reader configs inside them. I assumed a layout of your server response... You have a lot of trailing commas, by the way, I've marked some.


Ext.onReady(function(){

var logStore = new Ext.data.JsonStore({
autoLoad: true,
url: 'inc/config.php?list=messages',
//reader: new Ext.data.JsonReader({
root: 'messages',
fields: ['Message']//,
//})
});

var logGrid = new Ext.grid.GridPanel({
anchor: '100% 100%',
region: 'center',
store: logStore,
listeners:{
activate: function(){
logStore.reload();
}
},
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 1000,
sortable: true
},
columns:[
{id: 'Message', header: 'Message', dataIndex: 'Message'}//,
]
})
});

var centerPanel = new Ext.Panel({
layout: 'anchor',
region: 'center',
title: 'DHCP Log',
icon: 'inc/images/icons/email.png',
items: [logGrid]//,
});

var mainViewport = new Ext.Viewport({
layout: 'border',
items: [centerPanel]//,
});

});