PDA

View Full Version : XML datagrid not showing data... from Example.



kailuaboy
24 Apr 2010, 7:42 AM
Ok. So I want to display data from my XML file. So I decided to try the example file and see how its done. Well, I cant even see the data. The grid loads up just fine, but no data.

This is the example I am using:
http://www.extjs.com/deploy/dev/examples/grid/xml-grid.html

In the attachment, is what Ive got. This is straight from the examples, I didnt modify the code at all. And it still doesnt show up any data. :(

Here is the code:




Ext.onReady(function(){

// create the Data Store
var store = new Ext.data.Store({
// load using HTTP
url: 'sheldon.xml',

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'Item',
id: 'ASIN',
totalRecords: '@total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{name: 'Author', mapping: 'ItemAttributes > Author'},
'Title', 'Manufacturer', 'ProductGroup'
])
});

// create the grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: "Author", width: 120, dataIndex: 'Author', sortable: true},
{header: "Title", width: 180, dataIndex: 'Title', sortable: true},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
],
renderTo:'example-grid',
width:540,
height:200
});

store.load();
});



Like I said, I didnt change anything and still no data.

Ivan

mpawlowski
24 Apr 2010, 8:34 AM
did you include sheldon.xml (http://www.extjs.com/deploy/dev/examples/grid/sheldon.xml) in the same directory?

kailuaboy
24 Apr 2010, 8:39 AM
yes I did :)

fay
25 Apr 2010, 3:16 AM
Use FireFox and FireBug and take a look at what's returned by your server. Are you sure that you have it configured to read .xml files?

brink668
1 May 2010, 6:48 PM
I get the same exact problems.
It seems you have to have the website on a http server for it to work properly and not on a localhost or even launching from the directory.

rstuart
1 May 2010, 8:26 PM
My understanding is that all of the examples are written to work behind a web server. That is, if you want to run one of the examples, you need to have it on a running webserver, not just running from disk using file:// urls.

The same can be said for the API documentation that comes bundled with the ExtJS download. You can't just double click on the index.html and have it work. It needs to be served by a web server that supports php.