How to get value from the Store by id?
store in such fields
fields: [
{name: "id", type: 'int'},
{name: "name", type: 'String'},...
I need to get the id - name value.
I try so:
var rec = Ext.StoreMgr.lookup("MyStore").getById(id);
alert(rec.data.name);
what am I doing wrong?
The function getById
finds the record with the specified id which has nothing to do to with the id you specified in the fields config - Basically you're looking at record.id
while you should be looking at record.data.id
.
For 3.3.1 you should use:
var index = Ext.StoreMgr.lookup("MyStore").findExact('id',id);
var rec = Ext.StoreMgr.lookup("MyStore").getAt(index);