PDA

View Full Version : Grid is not displaying store data



Gowri Mogulluru
24 Jan 2014, 2:18 AM
Hi,
I am new to extjs4.2, i am using Ext.data.Store, iam getting the data from the db and trying to display in grid.

My code is:

Ext.onReady(function() {


var homeGridStore = Ext.create('Ext.data.Store', {
model: 'homegrid',
proxy: {
type: 'ajax',
url: 'getHomeGrid.action',

reader: {
type: 'json',
root:'gridDisplay'
}
},
autoLoad: true
});
Ext.define('homegrid', {
extend: 'Ext.data.Model',
fields: [ { name : 'unitnumber',type : 'string'},
{ name : 'unitname',type : 'string'},
{ name : 'status',type : 'string'},
{ name : 'locationname',type : 'string'},
{ name : 'speed',type : 'string'},
{ name : 'currentodo',type : 'string'},
{ name : 'nextservice',type : 'string'},
{ name : 'timehours',type : 'string'},
{ name : 'lastreporttime',type : 'string'},
{ name : 'reporttime',type : 'string'},

]
});

var win = Ext.create('Ext.Viewport', {
id: 'grid',
layout: 'border',
renderTo: Ext.getBody(),
items: [


Ext.create('Ext.grid.Panel', {
store: homeGridStore,
columns: [
{
width: 100,
header: 'Description',
dataIndex: 'unitname'


}, {
width: 130,
header: 'Last Report (dd:mm)',
dataIndex: 'reporttime'
}, {
width: 130,
header: 'Last Check (dd:mm)',
dataIndex: 'lastreporttime'
}, {
width: 100,
header: 'Status',
dataIndex: 'status'
}, {
width: 100,
header: 'Speed',
dataIndex: 'speed'
}, {
width: 100,
header: 'Odo (inKm)',
dataIndex: 'currentodo'
}, {
width: 150,
header: 'No Movement Since',
dataIndex: 'timehours'
}, {
width: 250,
header: 'Location',
dataIndex: 'locationname'
}],
width: 1200,
height: 100
})


]
});
});

output:

47698

nothing it is showing ,can any one tell how to display store values into the grid.

Thanks in Advance.

skirtle
24 Jan 2014, 2:57 AM
Please use [CODE] tags for posting code.

Your Ext.define calls should be outside the Ext.onReady. I suspect the problem in this case is that you're defining you model after you've tried to use it.

If that doesn't fix it, try logging out the store and dig into the data to see what's in there.

If you still can't fix it you should post a sample of the JSON returned by your server so we can check that.

Gowri Mogulluru
24 Jan 2014, 3:16 AM
Hi,

Thanks it is working fine now.. i placed the Ext.define from outside of the Ext.onReady.

Prasad_Guduri
8 Feb 2014, 11:09 AM
Hi,

Mark it as answered so that the people will not look into this to answer.

Thanks,
Prasad