【问题标题】:ExtJs - How to get value from the Store by id?ExtJs - 如何通过 id 从商店获取价值?
【发布时间】:2011-12-01 05:51:54
【问题描述】:

如何通过id从Store中获取价值?

存储在这些字段中

    fields: [
    {name: "id", type: 'int'},
    {name: "name", type: 'String'},...

我需要获取 id - name 值。

我试试看:

    var rec = Ext.StoreMgr.lookup("MyStore").getById(id);
    alert(rec.data.name);

我做错了什么?

【问题讨论】:

    标签: extjs store


    【解决方案1】:

    函数getById 查找具有指定id 的记录,该记录与您在字段配置中指定的id 无关 - 基本上您正在查看record.id,而您应该查看record.data.id

    对于 3.3.1,您应该使用:

    var index = Ext.StoreMgr.lookup("MyStore").findExact('id',id);
    var rec = Ext.StoreMgr.lookup("MyStore").getAt(index);
    

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 2013-05-16
      • 2016-04-22
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 2021-10-21
      相关资源
      最近更新 更多