Extjs 4在FormPanel内隐藏项目隐藏

时间:2017-12-09 07:56:15

标签: exception extjs hide

我正在使用extjs 4.当我想隐藏表单元素时,它会引发以下异常:

ext-all.js:54640 Uncaught TypeError: Cannot read property 'dom' of null
    at constructor.isValidParent (ext-all.js:54640)
    at constructor.getVisibleItems (ext-all.js:51850)
    at constructor.invalidate (ext-all.js:38511)
    at constructor.flushInvalidates (ext-all.js:38405)
    at constructor.run (ext-all.js:38727)
    at Function.flushLayouts (ext-all.js:31218)
    at Function.updateLayout (ext-extend.js:2973)
    at constructor.updateLayout (ext-all.js:32266)
    at constructor.onContentChange (ext-all.js:29697)
    at constructor.updateLayout (ext-all.js:32263)

表格是这样的:

this.ReqDetails = new Ext.FormPanel({
            width: 510,
            height: 600,
            style: ' padding:5px 5px 5px 5px',
            autoScroll: true,
            align: 'right',
            defaults: {
                labelWidth: 200,
                style: 'display:block; padding:1px 5px 1px 5px;font-weight: bold',
                layout: 'fit'
            },
            layout: {
                type: "table",
                columns: 2

            },
            // listeners:{'afterlayout':function(){RequestDetailsObject.ShowItem()}},

            items: [
                ...
            ]
            ,
            renderTo: this.get("RwqDetdiv"),
        });

逻辑是这样的:

var itemsToEnable = null;
                    if (enableItem != '') {
                        itemsToEnable = Ext.decode(enableItem);
                        console.log("enable items: ", itemsToEnable);
                    }
                    var win = RequestDetailsObject.ReqDetails;
                    var record = Ext.decode(response.responseText).DetList[0];
                    ...
                    win.down("[itemId=analyzer]").setValue("test");
                    ...

                    win.show();

                        if ((record.analyzer == null || record.analyzer == "") && (itemsToEnable == null || itemsToEnable.indexOf("analyzer") < 0)) {
                            win.getComponent("analyzerTit").hide();
                            win.getComponent("analyzer").hide();
                        }

错误发生在这一行:

win.getComponent("analyzerTit").hide();

值得注意的是win.down("[itemId=analyzerTit]").hide();也有相同的行为,win.down("[itemId=analyzer]").setValue("test");适用于上述代码。

1 个答案:

答案 0 :(得分:0)

由于您的DOM未创建,因此您遇到此问题。有关详细信息,请参阅此链接 SENCHA forum FIDDLE ,以了解Uncaught TypeError: Cannot read property 'dom' of nullerror

您可以使用以下代码

在最后处理此error
var analyzerTit = win.getComponent("analyzerTit");
if (analyzerTit && analyzerTit.getEl()) {
   analyzerTit.hide();
}