PDA

View Full Version : Set class to buttons



sanova
17 Aug 2012, 10:19 PM
Hi,
is there a way to set a class to buttons like this for example:



items: [
{
xtype: 'button',
id: 'button1',
..........,
class: 'classButton1'
},
{
xtype: 'button',
id: 'button2',
..........,
class: 'classButton1'
},
]


and then enable/disable button by class end not by id as follows:



Ext.getCmp('classButton1').enable()


It should be usefull if there are many buttons in different components that have to be enabled or disabled.

Thanks in advanced.

sword-it
17 Aug 2012, 10:43 PM
Hi,

You can use following config to give a class to button :




{
xtype:'button'
, id:'button1'
, cls:'classButton1'

}



for more detail see this link : http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Button-cfg-cls

sanova
17 Aug 2012, 10:45 PM
Solved.



cls: 'classButton1',


and then something like this:


for(var i=0; i<arrayFunc.length; i++){ Ext.select('.'+arrayFunc[i]).each(function(element){
var elementId = Ext.getCmp(element.id);
elementId.enable();
});
}

arrayFunc is array of functions i have to enable corresponding to class of buttons.