[英]extjs4 - Adding custom components to container
我正在尝试将自定义组件添加到ExtJS4容器中。 但是,当尝试在onRender方法中将项目添加到容器时,我收到错误消息:
无法从AbstractContainer中的doLayout读取“无法读取未定义的属性'layoutBusy'”。 未定义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);
}
});
我尝试使用容器的item配置属性添加组件,并且可以正常工作。 但是,我不确定如何将自定义参数传递给组件(需要将模型实例传递给组件)。
谢谢你的帮助。
看一下这个例子: 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'
});
(如果您拥有一个以上的组件,则适合的布局不是一个好的选择)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.