0

We are using extjs 3.4. The purpose is to replace a component in a Ext.Window. Even if there is no error when we remove the old and add the new component, when trying doLayout() the error Uncaught TypeError: Cannot read property 'offsetWidth' of undefined occurs.

The code that creates the window is:

    function createWindowConf(id, winconf, items) {
        var conf = {
            id: id,
            title: winconf.title, 
            iconCls: winconf.icon,
            x : winconf.xpos,
            y : winconf.ypos,
            width : parseInt(winconf.xsize), 
            height : parseInt(winconf.ysize),
            layout : winconf.layout, //'border',
            border : false,
            resizable : winconf.resizable,
            manager: windows,
            shadow: false,
            closable: true,
            items: items
        };
        var win = new Ext.Window(conf);
        win.render(desktopEl);
        return win;
    };

The items are a Ext.grid.GridPanel and a Ext.form.FormPanel. According to user's current selection in grip (component in position 0) the old form should be removed and a new should be added (component in position 1).

The code that creates the form is:

    var theConfig = {
    id: config.yid, 
            bodyStyle: 'padding:5px 5px 0',
            width: 370,
            maxWidth: 370,//not resizable
            minWidth: 370,
            layout: 'form',
            margins: '0 0 0',
            region: 'east',
            split: true,
            colapsible : true,
            trackResetOnLoad: true,
            autoScroll: true,
            fieldDefaults: {
                msgTarget: 'side',
                labelWidth: 75
            },
            items: [],
            buttons: [scopeDetails.updateButton, scopeDetails.submitButton]
    };
    this.detailsForm = new Ext.form.FormPanel(theConfig); 

and the items added afterwards.

The code that updates (adds/removes) components from the window is:

    this.updateWin = function(moduleForRemoveId, form, idWin) {
        var win = this.getWindow(idWin);
        if (win != null) {
            win.remove(moduleForRemoveId); 
            win.add(form);
            win.doLayout();
        }
    }

and produces the error in win.doLayout().

By removing all components and add the add the new ones:

    win.removeAll();
    win.add(this.grid);
    win.add(this.form);
    win.doLayout();

we have the same error.

Any suggestion will be really helpful since more than 3 days spent for that error

4

1 回答 1

1

我很确定错误来自其他东西,而不是组件删除/添加。我创建了一个简单的测试用例,它定义了一个带有表单和网格的窗口,以及一个用面板替换所有内容的按钮。它有效。

您的代码不完整。你应该提供一个完整的例子。您是否尝试过自己调试?在您的 Chrome 脚本调试器上启用“暂停未捕获的异常”以重现错误。您将获得所发生事件的堆栈跟踪,并提示您出了什么问题。当然包括 ext-all-debug。

于 2013-01-05T11:32:06.517 回答