开发者

ExtJs - How to get value from the Store by id?

开发者 https://www.devze.com 2023-04-11 00:49 出处:网络
How to get value from the Store by id? store in s开发者_开发知识库uch fields fields: [ {name: \"id\", type: \'int\'},

How to get value from the Store by id?

store in s开发者_开发知识库uch 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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号