I need to read content from a data source which is located on a remote server (I do not have access to modify anything).
I have tried to get the content, but it doesn't work.
What then I did was I downloaded this data source which is a XML file and put it under same folder with my code to test the correctness of my code syntax and found that the code works.
But when I changed back to the external data resource, it still reads but returns no content:
from: url: 'app/store/configuration.xml'
to: url: 'http://webtrak.bksv.com/mel/configuration'
This is not caused by CORS issue as I am testing my app on real devices.
Here are my store and model:
Ext.define('myApp.store.SensorStationStore', {
extend: 'Ext.data.Store',
requires: ['myApp.model.SensorStation', 'Ext.data.reader.Xml'],
config:{
model: 'myApp.model.SensorStation',
storeId: 'SensorStore',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'http://webtrak.bksv.com/mel/configuration',
//url: 'app/store/configuration.xml',
reader: {
type: 'xml',
record: 'locations',
rootProperty: 'nmts'
}
}
}
});
Ext.define('myApp.model.SensorStation', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'name',
type: 'string',
mapping: '@name'
//convert: function (value, record) {
// Ext.Msg.alert(value,record.raw);
// //var nodes = rec.raw.querySelectorAll('');
//}
},
{
name: 'lat',
mapping: '@latitude',
type: 'float'
},
{
name: 'lng',
mapping: '@longitude',
type: 'float'
},
{
name: 'locid',
mapping:'@locid',
type: 'string'
}
]
}
});
I figured out what's the problem is... I have never worked with XML so,I don't know how the response of ajax request look like ,but by applying following code for store will fill your app's store(just a little change in your code)
Code:
Ext.define('myApp.store.SensorStationStore', {
extend: 'Ext.data.Store',
requires: ['myApp.model.SensorStation', 'Ext.data.reader.Xml'],
config:{
model: 'myApp.model.SensorStation',
storeId: 'SensorStore',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'http://webtrak.bksv.com/mel/configuration',
//url: 'app/store/configuration.xml',
reader: {
type: 'xml',
record: 'locations',
rootProperty: 'nmts'
}
}
} });
You are trying to apply store configs outside of config object. Cheers!!