尝试扩展ExtJs ComboBox时出错-“无法读取null的属性\'dom\'”?

问题描述

| 我正在使用ExtJs4,并且尝试扩展ѭ0,如下所示:
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
以JSON格式返回商店(即“ 2”)的数据,如下所示:
\"combodata\":[
            {\"Key\":\"\",\"Value\":\"<None>\"},{\"Key\":\"!#\",\"Value\":\"Dr\"},{\"Key\":\"!$\",\"Value\":\"Miss\"}
        ]
但是,在ext-all-debug的第line4 get行出现错误。 (在renderActiveError方法内部)。 错误
Uncaught TypeError: Cannot read property \'dom\' of null
61312行:
me.errorEl.dom.innerHTML = activeError;
在这里错过明显的东西吗? 编辑:在我实例化的地方添加一些代码: 我实际上是动态实例化组合框,即服务器以JSON格式动态返回一些extjs代码,如下所示:
 {
    \"anchor\":\"50%\",\"autoScroll\":false,\"border\":false,\"combodata\":[
          {\"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]);
    ,        试试这个...将
constructor
中的所有内容移至
initComponent
方法中。然后在您的
constructor
中,您需要给父母的parent11ѭ打电话。
constructor : function(config) {
   GenericCombo.superclass.constructor.apply(this,new Array(config);
}
我还考虑为您的组件命名空间...像
Ext.ux.GenericCombo
这样的名称更合适。