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,
}
})
这是firebug中的记录返回,我试图用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,但仍然无法正常工作
答案 0 :(得分:0)
我不明白你为什么要使用idProperty?
看一下api-docs给出了一个简短的例子。你的代理阅读器应该看起来很相似,你的json就是这样。使用root属性。