Sencha Touch Reading XML data

grideryano

New Member
I have just recently started working with Sencha Touch 2.0. I am having problem in reading XML data. I started with basic "getting started" app which comes with the download and it is working fine which means I have done the setup correctly. Now I have made some changes to read simple XML but I am not able to see any data on screen. Below is my code. Please help me with this. - here are the contents of app.js file - \[code\]Ext.Loader.setPath({ 'Ext': 'lib/touch/src'});Ext.define('User', { extend: 'Ext.data.Model', config: { fields: ['id', 'name', 'email'] }});var mystore = Ext.create('Ext.data.Store', { model: 'User', autoLoad: true, proxy: { type: 'ajax', url : 'userData.xml', reader: { type: 'xml', rootProperty: 'users', record: 'user' } }}); Ext.application({ name: 'Sencha', launch: function() { //The whole app UI lives in this tab panel Ext.Viewport.add({ xtype: 'tabpanel', fullscreen: true, tabBarPosition: 'bottom', items: [ // This is the home page, just some simple html { title: 'Home', iconCls: 'home', cls: 'home', scrollable: true, html: [ '<img height=260 src="http://staging.sencha.com/img/sencha.png" />', '<h1>Welcome to Sencha Touch</h1>', "<p>Building the Getting Started app</p>", '<h2>Sencha Touch (2.0.0)</h2>' ].join("") }, { xtype: 'list', title: 'Events', iconCls: 'star', itemTpl: '{id}', store: mystore } ] }); }});\[/code\]The XML is at the same location as this app.js file. Please note that I have not installed any server. I just make changes to app.js and open "index.html" in chrome browser. Here is the XML. It is same as the one given on Sencha Docs.-\[code\]<?xml version="1.0" encoding="UTF-8"?><users><user> <id>112</id> <name>Ed Spencer</name> <email>[email protected]</email></user><user> <id>248</id> <name>Abe Elias</name> <email>[email protected]</email></user></users>\[/code\]Here is my code after changes - \[code\]Ext.Loader.setPath({ 'Ext': 'lib/touch/src'});Ext.regModel('Personal', { fields : [ 'id', {name: 'name', type: 'string'}, {name: 'email', type: 'string'} ]});Ext.application({ name: 'Sencha', launch: function() { //The whole app UI lives in this tab panel Ext.Viewport.add({ xtype: 'tabpanel', fullscreen: true, tabBarPosition: 'bottom', items: [ // This is the home page, just some simple html { xtype : 'selectfield', name : 'user', label : 'Users', store : new Ext.data.Store({ model : 'Personal', autoLoad : true, proxy : { type : 'ajax', url : 'userData.xml', reader : { type : 'xml', root : 'users' } } }), valueField : 'name', displayField : 'name' } ] }); }});\[/code\]
 
Back
Top