PDA

View Full Version : Need to enable/disable buttons in same Toolbar



cryovirus
15 Sep 2010, 10:47 PM
Hello @ all!

Im working on a presentation for the iPad.

I'm new to Sencha Touch but I had managed to program the things i needed until this point:

I have to enable/disable Buttons within one Toolbar:


var tbar = new Ext.Toolbar({
dock:'bottom',
xtype: 'toolbar',
cls: 'cntr',
items: [{
text: 'Startseite',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(0, 'slide');
}
},{
text: 'page 1',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(1, 'slide');


// this button should activate the 'stats'-button :-/


}
},{
text: 'page 2',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(2, 'slide');
}
},{
text: 'page 3',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(3, 'slide');
}
},{
cls: 'space',
},{
text: 'Infos',
handler: getinfo,
cls: 'infos',
disabled: true
},{
text: 'Stats',
handler: getstats,
cls: 'infos',
disabled: true
}]
});


I had tried something like:

var mybutton = panel.getComponent(tbar).getItems();

but i have no idea how to get the 'stats'-button to set him activ with:

mybutton.setDisabled(false);

pls help :((

evant
15 Sep 2010, 11:01 PM
Give the stats button an itemId,



itemId: 'stats'

//
var button = tbar.getComponent('stats');

cryovirus
15 Sep 2010, 11:10 PM
thanks a lot!

here my code:


var tbar = new Ext.Toolbar({
itemId: 'bar',
dock:'bottom',
xtype: 'toolbar',
cls: 'cntr',
items: [{
text: 'Startseite',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(0, 'slide');
var btn = tbar.getComponent('stats');
btn.setDisabled(false);
}
},{
text: 'Seite 1',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(1, 'slide');
}
},{
text: 'Seite 2',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(2, 'slide');
}
},{
text: 'Seite 3',
handler: function(){
var car = panel.getComponent(carousel);
car.setCard(3, 'slide');
}
},{
cls: 'space',
},{
itemId: 'info',
text: 'Infos',
handler: getinfo,
cls: 'infos',
disabled: true,
},{
itemId: 'stats',
text: 'Stats',
handler: getstats,
cls: 'infos',
disabled: true,
}]
});

... still work'n on it^^