我加载了一个 json 存储,我需要从中获取一条记录。我用过:、、、,getAt(index)
但没有结果。这是我的代码:find()
getById()
var appSettingReader = new Ext.data.JsonReader({
root: 'results',
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'projetId', type: 'int', mapping: 'projetId'},
{name: 'resLevels', type: 'int', mapping: 'resLevels'},
{name: 'maxResToLock', type: 'int', mapping: 'maxResToLock'},
{name: 'maxTimeToLock', type: 'int', mapping: 'maxTimeToLock'},
{name: 'infosToPrint', type: 'string', mapping: 'infosToPrint'}
])
var appSettingStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'inc/getSettings.php',
method: 'POST'
}),
baseParams:{task: "app"},
reader : appSettingReader,
sortInfo:{field: 'id', direction: "DESC"}
})
appSettingStore.load();
此代码返回未定义:
console.log(appSettingStore.getAt(0));
console.log(appSettingStore.find("id","1"));
这是从服务器返回的 json 字符串:
{success:true,"results":[{"id":"1","projetId":"1","resLevels":"1","maxResToLock":"40","maxTimeToLock":"10","infosToPrint":"1_2_3_5","hotlineMail":"admin@app.com"}]}
我还测试了这段代码:
var records = new Array()
var test = appSettingStore.each(function(rec){
records.push(rec)
})
console.log(records)
我得到一个空数组!
PS:本店不绑定任何组件;我只想读写它。