Ext.define('GoogleMarkerModel', {
extend: 'Ext.data.Model',
fields: ['ID','Locating','MainPower','Acc','PowerOff','Alarm','Speed','Direction','Latitude','Longitude','DateTime','MainID','IOState','OilState']
});
var MarkerStore = Ext.create('Ext.data.JsonStore', {
model: 'GoogleMarkerModel',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'get-googlemarker.php',
baseParams: { //here you can define params you want to be sent on each request from this store
mainid: 'value1'
},
reader: {
type: 'json',
}
}
});
MarkerStore.load({
params: {
mainid: 1,
}
})
这是萤火虫中的记录返回,我试图用alert(MarkerStore.getCount());
返回 0 计算记录?为什么?
我仔细检查了字段名称,一切都是正确的。这是怎么回事?
[{"ID":"1808","Locating":"1","MainPower":"0","Acc":"1","PowerOff":"1","Alarm":"128","Speed":"0","Direction":"293","Latitude":"5.391788482666016","Longitude":"100.29693603515625","DateTime":"2013-02-19 15:44:36","MainID":"1","IOState":"0","OilState":"0"}]
更新
Ext.define('GoogleMarkerModel', {
extend: 'Ext.data.Model',
idProperty:'MainID',
fields: ['ID','Locating','MainPower','Acc','PowerOff','Alarm','Speed','Direction','Latitude','Longitude','DateTime','MainID','IOState','OilState']
});
var MarkerStore = Ext.create('Ext.data.JsonStore', {
model: 'GoogleMarkerModel',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'get-googlemarker.php',
baseParams: { //here you can define params you want to be sent on each request from this store
mainid: 'value1'
},
reader: {
type: 'json',
idProperty : 'MainID',
}
}
});
我添加了 idproperty,但仍然无法工作