我有以下商店: Ext.define('Sencha.model.MenuPoint', {extend: 'Ext.data.Model',config: { fields: [ {name: 'id', type: 'string'}, // this is id of the element, example child id, report id, and so fourth //{name: 'elementId', type: 'int
Ext.define('Sencha.model.MenuPoint', { extend: 'Ext.data.Model', config: { fields: [ {name: 'id', type: 'string'}, // this is id of the element, example child id, report id, and so fourth //{name: 'elementId', type: 'int'}, {name: 'name', type: 'string'}, {name: 'icon_url', type: 'string'}, {name: 'xtype', type: 'string'} ] } });
我设法插入和检索这样的值:
var keyValue = new Object(); keyValue.key = "adultId"; keyValue.value = adultObj.adultId; console.log("keyValue: "+keyValue); var sessionStore = Ext.getStore('MySessionStore'); sessionStore.add(keyValue); sessionStore.sync(); var index = sessionStore.find('key',keyValue.key); console.log("index: "+index); var keyValue2 = sessionStore.getAt(index); console.log("keyValue2: "+keyValue2);
但是首先获取索引,然后获取值,这样做很麻烦,不可能做到这样的事情:
var value = store.get(key);
?
你可以使用功能var record = store.findRecord('id', key)
它是一个快捷方式
index = store.find('id', key); record = index != -1 ? store.getAt(index) : null;
干杯,奥列格