Hey all,
got some problems with nested XML in Sencha Touch 2. My code is based on an example with JSON: http://www.sencha.com/forum/showthre...ON-and-hasMany
I'm getting "There are 0 matches" on the console.
So what do I have to change on my code to get the "matches"?
data.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<jobs>
<job>
<jobId>334</jobId>
<phone>245234</phone>
<matches>
<match>
<matchId>43</matchId>
<status>M_NEW"</status>
</match>
<match>
<matchId>42</matchId>
<status>M_NEW"</status>
</match>
<match>
<matchId>45555</matchId>
<status>M_NEW"</status>
</match>
</matches>
</job>
<job>
<jobId>406</jobId>
<phone>55333555</phone>
<matches>
<match>
<matchId>46789</matchId>
<status>M_NEW"</status>
</match>
</matches>
</job>
</jobs>
MatchModel
Code:
Ext.define('Simplestore9.model.MatchModel', {
extend : 'Ext.data.Model',
config : {
idProperty : 'matchId',
fields : [
'matchId',
'status'
]
}
});
JobModel
Code:
Ext.define('Simplestore9.model.JobModel', {
extend: 'Ext.data.Model',
config: {
fields : [
{
name : 'jobId',
type : 'int'
},
{
name : 'phone'
}
],
hasMany : [
{
model : 'Simplestore9.model.MatchModel',
name : 'matches',
associationKey : 'matches'
}
]
}
});
Loading the Store:
Code:
var store = Ext.create('Ext.data.Store', {
model: 'Simplestore9.model.JobModel',
proxy: {
type : 'ajax',
url : 'resources/data/data.xml',
reader: {
type: 'xml',
record: 'job',
rootProperty: 'jobs'
}
},
listeners : {
load : function(store) {
var rec = store.getAt(0);
var matches = rec.matches();
console.log('There are ' + matches.getCount() + ' matches');
}
}
});
store.load();