[英]Parent Class, Extends Ext.form.Panel, Add DockedItmes
I've got a parent class ParentPanel
that extends Ext.form.Panel
in Ext JS 5. The parent panel is roughly defined as follows: 我有一个父类
ParentPanel
,它在Ext JS 5中扩展了Ext.form.Panel
。父面板大致定义如下:
Ext.define('...ParentPanel', {
config : {
isItTrue : true
},
dockedItems: [],
initComponent : function () {
var me = this;
//If some evaluation is true...
if (isItTrue) {
me.dockedItems.push({
// the components I am trying to add...
});
this.callParent():
}
//....
The basic problem is that any class extending ParentPanel
will call the initComponent
function, adding the items to the parent dockedItems
config. 基本问题是,任何扩展
ParentPanel
类都将调用initComponent
函数,并将这些项添加到父 dockedItems
配置中。 for every true
evaluation (so I end up with repetitions as each child is sharing the parent's dockedItems
config.). 对于每一次
true
评估(因此我最终会重复,因为每个孩子都共享父母的dockedItems
配置。)。 What I want to do is to only have the item added to the inheriting classes dockedItems
configuration, not the parent. 我想要做的是只有有项目加入到继承类
dockedItems
配置,而不是父母。
Is this even possible is Ext JS? Ext JS甚至可能吗? If so, understanding the design issue, how would I work around this?
如果是这样,了解设计问题,我将如何解决?
Something like this: 像这样:
initComponent: function () {
this.dockedItems = [];
// ...
}
ExtJS doesn't change the nature of Javascript... ExtJS不会改变Javascript的性质...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.