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'
}
]
},
proxy: {
type: 'ajax',
url: 'http://webtrak.bksv.com/mel/configuration',
reader: {
type: 'xml',
record:'locations',
rootProperty: 'nmts'
}
}
});
Ext.define('myApp.store.SensorStationStore', {
extend: 'Ext.data.Store',
requires: ['myApp.model.SensorStation'],
config:{
model: 'myApp.model.SensorStation',
storeId: 'SensorStore'
},
autoLoad: true
});
Ext.define('myApp.controller.SensorStations', {
extend: 'Ext.app.Controller',
requires: ['Ext.MessageBox'],
config: {
refs: {
mapComponent: 'main map'
},
control: {
mapComponent: {
maprender: 'onMaprender'
}
}
},
onMaprender: function (mapComponent, googleMap) {
var store, latlng, marker;
// Use Store name when testing on devices
// Use Store ID when testing in browsers
var sensorStore = Ext.data.StoreManager.get('SensorStore');
if (!sensorStore) {
console.log("Store not found");
Ext.Msg.alert('error', "store not found");
return;
}
//else {
// console.log("Store found");
// Ext.Msg.alert('great', "store found");
// //return;
//}
sensorStore.load({
callback: function (records, operation, success) {
mapComponent.setMapOptions({
center: new google.maps.LatLng(-37.899328, 144.843333)
});
if (success) {
Ext.Msg.alert('success', records);
}
else {
Ext.Msg.alert('error', operation);
}
Ext.Msg.alert('records.count = ' + records.length, 'haha');
}
});
}
});
records.length始终为0。 你能指出我出错的地方吗?
此外,我想知道记录的数据结构。
非常感谢
答案 0 :(得分:0)
在您的模型中,将proxy: {}
置于config:{}
内,将autoload: true
放入config:{}