Sencha Touch – Ajax JSON with multiple roots

I have JSON result that contains multiple roots.
Most example JSONReader source codes are dealing with one root.

According to cnelissen from Sencha Forum, using below code will make it working:

var store1 = new Ext.data.Store({
url: '/path/to/json-data.php',
method: 'POST',
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'root1',
fields: ['field1', 'field2', 'field3']
}),
listeners: {
'load': function() {
store2.loadData(store1.reader.jsonData);
}
}
});

var store2 = new Ext.data.Store({
reader: new Ext.data.JsonReader({
root: 'root2',
fields: ['field1', 'field2', 'field3']
})
});

 

Thx, cnelissen.