PDA

View Full Version : Create a TreePanel using XmlReader



iNes14
21 Feb 2012, 3:02 AM
Hello everybody.

Everything is in the title, I want to create a TreePanel and load data since a xml using a XmlReader.

Xml is like



<?xml version="1.0" encoding="UTF-8"?><user> <id>1</id> <name>Ed Spencer</name> <email>[email protected]</email></user><user> <id>2</id> <name>Abe Elias</name> <email>[email protected]</email></user>


Can you help me ?

Thank you,

mitchellsimoens
21 Feb 2012, 6:18 AM
Try setting the records config to 'user'

iNes14
22 Feb 2012, 12:37 AM
I have already do that :



Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'email']
});

var store = new Ext.data.Store({
url: 'users.xml',
model:'User',
reader: new Ext.data.XmlReader({
record: 'user'
})
});


But I got the error : "me.store.getRootNode is not a function"

mitchellsimoens
22 Feb 2012, 5:05 AM
Your store isn't setup correctly, it doesn't have a url or reader config, those should be within the proxy config:


new Ext.data.Store({
model : 'User',
proxy : {
type : 'ajax',
url : 'users.xml',
reader : {
type : 'xml',
record : 'user'
}
}
});

iNes14
22 Feb 2012, 5:10 AM
It doesn't work better ... :(