PDA

View Full Version : Binding xml file to a data grid



vaishalishah
8 Feb 2010, 6:53 AM
Hi,
I am unable to bind the xml file to a datagrid. The store finishes to load but the data grid is empty. No exception is display. Could someone pls help asap . The souce code is as follows of the js file and xml file.


Ext.onReady(function(){


var colModel =new Ext.grid.ColumnModel({
columns:[
{id:'common',header:'Common',dataIndex:'common'},
{header:'Botanical',dataIndex:'botanical'}
]
});

var store =new Ext.data.Store({
url :'/Extjs6/WebContent/plants.xml',
reader: new Ext.data.XmlReader({
record:'plant'},
[
{name: 'common'},
{name:'botanical'}]
)
});



var grid =new Ext.grid.GridPanel({
autoDestroy:true,
store: store,
cm:colModel,
width:600,
height:600,
renderTo:document.body
});
grid.render();


store.load({
callback: function(){

Ext.Msg.alert('Hello world',store.getTotalCount().toString());
}
});

});



Xml File
________


<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<plant>
<common>Bloodroot</common>
<botanical>Sanguinaria canadensis</botanical>
</plant>
</catalog>