简体   繁体   English

extjs4-将自定义组件添加到容器

[英]extjs4 - Adding custom components to container

I'm trying to add custom components to an ExtJS4 container. 我正在尝试将自定义组件添加到ExtJS4容器中。 However, when trying to add items to the container in the onRender method, I am receiving the error: 但是,当尝试在onRender方法中将项目添加到容器时,我收到错误消息:

'Cannot read property 'layoutBusy' of undefined' from the doLayout in AbstractContainer. 无法从AbstractContainer中的doLayout读取“无法读取未定义的属性'layoutBusy'”。 The componentLayout property is not defined. 未定义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);
    }
});

I've tried adding the components using the container's item configuration property and it works. 我尝试使用容器的item配置属性添加组件,并且可以正常工作。 However, I'm not sure how to pass custom parameters over to the component (need to pass model instances to the component). 但是,我不确定如何将自定义参数传递给组件(需要将模型实例传递给组件)。

Thanks for any help. 谢谢你的帮助。

Have a look at this example: http://jsfiddle.net/ChE59/ 看一下这个例子: http : //jsfiddle.net/ChE59/

I'm adding 3 panels to the container and passing in some custom property. 我将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'
});

(fit layout is not a good choice if you've got more the one component) (如果您拥有一个以上的组件,则适合的布局不是一个好的选择)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM