【问题标题】:grid itemdblclick is failing with Cannot read property 'internalId' of undefined网格 itemdblclick 失败,无法读取未定义的属性“internalId”
【发布时间】:2014-02-28 00:49:58
【问题描述】:

双击网格中的一行时出现问题,出现错误:

Uncaught TypeError: Cannot read property 'internalId' of undefined 

这是我的活动代码:

itemdblclick : function (view, record, item, index, eventOptions) {
                            console.log(record);
                            me.unassignedGrid.getStore().add(record);
                            removedDevices.push(record);
                            me.assignedGrid.getStore().remove(record);
                        }

当我调试代码时,错误指向:粗体行:i = 4,但记录仅包含 4 个元素。是不是很奇怪? (下面的代码来自 ext-all-debug.js v 4.1.3)

updateIndexes : function(startIndex, endIndex) {
        var ns = this.all.elements,
            records = this.store.getRange(),
            i;

        startIndex = startIndex || 0;
        endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
        for(i = startIndex; i <= endIndex; i++){
            ns[i].viewIndex = i;
            **ns[i].viewRecordId = records[i].internalId;**
            if (!ns[i].boundView) {
                ns[i].boundView = this.id;
            }
        }
    },

【问题讨论】:

    标签: javascript extjs4.1


    【解决方案1】:

    我可能遗漏了一些东西,但是如果我在添加之前添加以下内容,为什么它会起作用?

    me.unassignedGrid.getStore().load();
    

    【讨论】:

    • itemdblclick 属于哪个网格,我看到你有 unassignedGrid 和assignedGrid。另一件事是您必须克隆记录,然后将记录从一个商店复制到另一个。
    • itemdblclick 属于assignedgrid。如果两个grid的store同款,为什么要克隆记录?
    【解决方案2】:

    每条记录都有一个 id,当你复制它时,它也会复制 id,这与商店之间的唯一性冲突。当您克隆时,您会获得一个新 ID,并且可以在两个商店中正常工作。您可以这样做

    Ext.clone (record.copy().data).
    

    当您说添加me.unassignedGrid.getStore().load(); 时它会工作时,您的商店正在重新加载并且其中的记录获得新的ID,这些不会与您在itemdblclick 中的先前记录冲突。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-22
      • 2017-06-07
      • 2018-06-15
      • 1970-01-01
      • 2023-01-30
      • 2019-02-05
      • 1970-01-01
      • 2020-01-24
      相关资源
      最近更新 更多