javascript - 尝试扩展 ExtJs ComboBox 时出错 - "Cannot read property ' dom' of null”?

标签 javascript extjs null extjs4

我正在使用 ExtJs4,我正在尝试扩展 Ext.form.field.ComboBox,如下所示:

Ext.define('GenericCombo', {
  extend: 'Ext.form.field.ComboBox',
  alias: 'widget.genericcombo',

  //the constructor
  constructor: function(config) {

    var store = new Ext.data.JsonStore({
        fields: ['Key', 'Value'],
        data : config.combodata || []
    });//new Ext.data.Store

    Ext.apply(this, config, {
        store: store,
        displayField: 'Value',
        valueField: 'Key',
        queryMode: 'local',
        emptyText:'Select a value...'
    });

    this.callParent([this]);

  }//end constructor

});//end Ext.define

商店的数据,即 config.combodata 以 JSON 格式返回,如下所示:

"combodata":[
            {"Key":"","Value":"<None>"},
            {"Key":"!#","Value":"Dr"},
            {"Key":"!$","Value":"Miss"}
        ]

但是我在 ext-all-debug 的 61312 行上收到错误。
(在 renderActiveError 方法内)。

错误:未捕获类型错误:无法读取 null 的属性“dom”

第 61312 行:

me.errorEl.dom.innerHTML = activeError;

我在这里遗漏了一些明显的东西吗?

编辑:在实例化它的地方添加一些代码:
我实际上动态实例化组合框,即服务器以 JSON 格式动态返回一些 extjs 代码,如下所示:

 {
    "anchor":"50%",
    "autoScroll":false,
    "border":false,
    "combodata":[
          {"Key":"","Value":"<None>"},
          {"Key":"!#","Value":"Dr"}
        ],
    "fieldLabel":"Title",
    "name":"3820",
    "value":"!)",
    "xtype":"genericcombo"
 }

但是,当我尝试对其进行硬编码时,我遇到了相同的错误。硬编码示例:

            xtype: 'form',
            title: 'A Form',
            items:[{
                     xtype: 'genericcombo',
                     fieldLabel: 'Test',
                     combodata: [{Key: 'one', Value: 'two'}]
                  }]

最佳答案

我正在打电话

this.callParent([this]); //Which is wrong and caused my error.

正确的方法是调用

this.callParent([arguments]);

关于javascript - 尝试扩展 ExtJs ComboBox 时出错 - "Cannot read property ' dom' of null”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6178418/

相关文章:

javascript - HTML5 Canvas 游戏生成间隔

javascript - 控制台中的 Angular : get the scope I created (not the whole scope)

extjs - 无法在网格中添加过滤器

javascript - JavaScript 中未定义的 ruby​​ 对象

java - 空检查链与捕获 NullPointerException

javascript - 如何阻止文本中的脚本标签执行?

javascript promise 、缓存和 Angular

css - 将 Extjs 面板背景样式更改为 Buttongroup 的背景样式

c++ - 为什么 c++wt 没有与 ExtJs 3.x 集成?以及如何将它与它整合?

pointers - Go中通过反射修改struct中的空指针字段