PDA

View Full Version : Problems with Ext.grid.GridPanel, can't get data from JsonStore



Xenon1170
25 Sep 2010, 6:56 AM
Hi! Today I was tryin' to make a grid loading it's data (store) from a php page that gives me json data:

Here is my code:


var articlesStore = new Ext.data.JsonStore({
root : 'articles',
idProperty : 'id',
fields: [
'id',
'name',
'value',
],
url: 'get.articles.php'
});

var articlesTable = new Ext.grid.GridPanel({
height: 500,
border: false,
store: articlesStore,
columns : [
{
header: "Name",
width: 120,
dataIndex: 'name'
},
{
header: "Value",
width: 80,
dataIndex: 'value'
},
]
});
Json data automatically generated by get.articles.php:


{"articles":[{"id":"1","name":"Try","value":"99.99"},{"id":"2","name":"Try2","value":"54.78"}]}The grid is rendered to a panel as item:


new Ext.Panel({
title : 'Articles management',
iconCls : 'icon-articles',
renderTo: 'content',
height: 500,
items: [articlesTable]
});Firebug tells me there isn't any XHR request...

Any suggestion? Why doesn't my code works?

bruijn88
25 Sep 2010, 9:55 AM
Try:



var articleStore = new Ext.data.JsonStore({
autoLoad: true,
// .. the rest
});
or:


// create store/grid

articleStore.load();
Zogs.

Xenon1170
25 Sep 2010, 11:13 AM
It works! ... No comment... XD such a simply thing... XD

Thanks!!!