PDA

View Full Version : Extension child element config



lvcoder
6 Jun 2011, 2:51 AM
Her is par of my code:


Ext.ux.AP = Ext.extend(Ext.Window,{
title:'selector'
,width: 400
,height: 400
,layout: {type:'vbox',align: 'stretch'}
,modal: true
,submitDisabled: true
,closeAction: 'hide'
,bbar: {
xtype: 'toolbar'
,layout: 'hbox'
,items: [
{
xtype:'spacer',
flex:1
},
{
xtype: 'button',
margins:'5',
text: 'choose',
disabled: false , // *****
listeners: {
click: function(){ this.ownerCt.ownerCt.AddressSet(this.ownerCt.ownerCt.selId,this.ownerCt.ownerCt.VZDId); }
}
}
]
}

...




How to pass submitDisabled on disabled marked with stars.
e.g. I need to configure child elements.

skirtle
6 Jun 2011, 6:00 PM
Like this:


Ext.ux.AP = Ext.extend(Ext.Window, {
closeAction: 'hide',
height: 400,
layout: {type:'vbox', align: 'stretch'},
modal: true,
submitDisabled: true,
title: 'selector',
width: 400,

initComponent: function() {
this.bbar = [
'->',
{
disabled: this.submitDisabled,
text: 'choose',
listeners: {
click: function() { ... }
}
}
];

Ext.ux.AP.superclass.initComponent.call(this);
}
});

The important bit is overriding initComponent(). I also got rid of the hbox on the toolbar but you can put it back in if you really want it. If you need to override the bbar on a further subclass or a specific instance you could switch to using Ext.applyIf(this, {bbar: ...}) in initComponent() to add the bbar instead.

lvcoder
7 Jun 2011, 7:22 AM
thank you!