0
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,但仍然无法工作

4

1 回答 1

0

我不明白你为什么使用 idProperty?

看看api-docs会给你一个简短的例子。你的代理阅读器应该看起来很相似,你的 json 也应该如此。使用根属性。

于 2013-02-23T10:17:24.423 回答