1

我正在尝试将自定义组件添加到 ExtJS4 容器。但是,当尝试在 onRender 方法中将项目添加到容器时,我收到错误消息:

'无法从 AbstractContainer 中的 doLayout 读取属性'layoutBusy' of undefined'。未定义 componentLayout 属性。

Ext.define('App.view.dashboard.RightContainer', {   
    extend: 'Ext.container.Container',
    uses: [
        'App.view.Component1',
        'App.view.Component2'
    ],

    alias: 'widget.dashboardright',
    layout: 'fit',
    border: 0,

    onRender: function() {

        var self = this;
        self.callParent(arguments);

        var component1 = Ext.create('App.view.Component1', {
            height: '300px',
            flex: 1,
            incidents: self.dashboard.get('incidents')
        });

        var component2 = Ext.create('App.view.Component2', {
            flex: 1,
            contact: self.dashboard.get('contacts')
        });

        self.add(component1);
        self.add(component2);
    }
});

我尝试使用容器的项目配置属性添加组件并且它有效。但是,我不确定如何将自定义参数传递给组件(需要将模型实例传递给组件)。

谢谢你的帮助。

4

1 回答 1

1

看看这个例子:http: //jsfiddle.net/ChE59/

我正在向容器中添加 3 个面板并传入一些自定义属性。

Ext.define('App.view.dashboard.RightContainer', {   
    extend: 'Ext.container.Container',
    alias: 'widget.dashboardright',


    border: 0,

    constructor: function(config){
        Ext.apply(this, {
            items: [
                { 
                    title: 'panel 1'
                },
                { 
                    title: 'panel 2'
                },
                {
                    title: config.customParameter
                }
            ]     
        });

       this.callParent(arguments);        
    }
});


Ext.widget('dashboardright', {
    renderTo: Ext.getBody(),
    customParameter: 'custom parameter'
});

(如果您有更多一个组件,则适合布局不是一个好的选择)

于 2012-05-02T19:47:27.090 回答