I am using Sencha Touch and trying to get data from a remote server
Here is my store
and my controller
And this is the data source : http://ift.tt/1fuX97P
Please help me make it work in devices~~~ thank you
Here is my store
Code:
Ext.define('webTrak.store.NoiseStore', {
extend: 'Ext.data.Store',
requires: ['webTrak.model.noiseChunk', 'Ext.data.reader.Xml'],
config:{
autoLoad: true,
storeId: 'NoiseStore',
model: 'webTrak.model.noiseChunk',
proxy: {
type: 'ajax',
//url: "http://ift.tt/1fbg3po'http%3A%2F%2Fwebtrak.bksv.com%2Fmel%2Fdata%2F46610526'&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=",
url: 'http://ift.tt/1fuX97P',
//url:'app/store/now.xml',
reader: {
type: 'xml',
//rootProperty: 'results',
record: 'data'
}
}
}
});
and my controller
Code:
noiseStore.load({
callback: function (records, operation, success) {
myop = records;
if (!success) {
Ext.Msg.alert('Failed!', records[0]);
}
else
{
Ext.Msg.alert('Success!', $(records[0].raw).html());
}
var lines = $(records[0].raw).html().split('\n');
//var lines = records[0].raw.innerHTML.split('\n');
Ext.Msg.alert('number of lines', lines);
Ext.Object.each(lines, function (key, value, myself) {
//window.setInterval(function () { }, 1000);
Ext.Function.defer(function () {
var fields = value.split(',');
var isNoise = fields[0];
if (isNoise === 'noise') {
console.log('noise = ' + fields[5]);
Ext.Msg.alert('noise', fields[5]);
var locid = fields[3];
var noisevalue = fields[5];
var overlayTmp = new Ext.Template('<div class="overlay">{noiseValue}</div>', { compiled: true });
overlayTmp.compile();
var overlayHtml = overlayTmp.apply({ noiseValue: noisevalue });
var tempOverLay = sensorSet[locid];
tempOverLay.onRemove();
sensorSet[locid].setValues({
content: overlayHtml
});
sensorSet[locid].onAdd();
sensorSet[locid].draw();
}
else {
console.log('radar = ' + fields[10]);
}
}, 2000);
//window.setInterval(function () {
//}, 1000);
});
}
});
And this is the data source : http://ift.tt/1fuX97P
Please help me make it work in devices~~~ thank you
Aucun commentaire:
Enregistrer un commentaire