I am new to Sencha Touch framework. I need to load some data from an XML file into a List. Right now I am just trying to make the XMLReader example given in the documentation work.
When I try to run the below mentioned code, I get an error message:
Javascript error on Line 7212
sencha-touch-debug.js
TypeError: Result of expression 'records' [undefined] is not an object.
Code – index.js:
Ext.setup({
onReady: function(){
Ext.regModel('User1', {
fields: ['id', 'name','email']
});
var temp = new Ext.data.Store({
model: 'User',
autoLoad:true,
proxy: {
type: 'ajax',
url : 'users.xml',
reader: {
type: 'xml',
record: 'user'
}
}
});
var list = new Ext.List({
fullscreen: true,
itemTpl : '{id} {name}',
store: temp
});
list.show();
}
});
users.xml
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user>
<id>1</id>
<name>Ed Spencer</name>
<email>ed@sencha.com</email>
</user>
<user>
<id>2</id>
<name>Abe Elias</name>
<email>abe@sencha.com</email>
</user>
</users>
I know its a very small thing that I am missing, but I’m not sure what it is. I tried the solution mentioned in this post, but it doesn’t work for me.
I dit notice you didn’t define the root node of the xml file.
Not sure if this is the only thing, try it out and let me know!