PDA

View Full Version : Problem loading XML store



alejandroNNU
20 Nov 2013, 3:46 PM
Hello, I am having a problem loading an XML store and I desperately need to find out a solution for it, the problem is as follows: I make a request to a server which returns an XML document that looks like this:

<result>
<row>
<sysid>7</sysid>
<status>Active</status>
<city>Carrollton</city>
<state>GA</state>
</row>
<row>
<sysid>8</sysid>
<status>Active</status>
<city>Atlanta</city>
<state>GA</state>
</row>
</result>

the problem is I can't load these records into the store, I created an XML store, but first off I'm not sure what my model should look like, I'm only interested in sysid and status, so I created a model with only two fields and named them respectively, then I'm not sure what the config should be for the XMLReader and the AjaxProxy, do I need to specify a url? do I need to specify a root? what should they be? I've never used an XML Store before so I have no clue what I'm missing. This is what the store and model look like:


Ext.define('MyApp.store.LocationStore', {
extend: 'Ext.data.Store',


requires: [
'MyApp.model.LocationModel'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'MyApp.model.LocationModel',
storeId: 'MyXmlStore',
proxy: {
type: 'ajax',
reader: {
type: 'xml'
}
}
}, cfg)]);
}
});



Ext.define('MyApp.model.LocationModel', {
extend: 'Ext.data.Model',


fields: [
{
name: 'sysid'
},
{
name: 'status'
}
]
});


The function that's supposed to load the data into the store is the following:


procQexResult: function(response, orgScope, action) {
var s = Ext.data.StoreManager.lookup('LocationStore');
s.loadRawData(response.responseXML);
}


response.responseXML is the XML document I get back from the server which looks exactly as I detailed it above, when I run it though I get the following error:

Uncaught TypeError: Cannot call method 'split' of undefined ext-all.js:21

Which seems to be caused when I do the s.loadRawData, should I be using something else? Like I said I'm lost as to whether the problem lies in the model, store, function or all three, so if someone could please provide me with any help on this it would be greatly appreciated.

evant
20 Nov 2013, 3:55 PM
1) If you're developing, use ext-all-dev, you would have got an error saying you're missing the record config

2) You're missing the record config on the reader

alejandroNNU
20 Nov 2013, 4:35 PM
that did it, thank you so much, and forgive my ignorance but how do I use ext-all-dev?

evant
20 Nov 2013, 4:37 PM
Include ext-all-dev, not ext-all.