我有以下商店:
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);
?