Reputation: 943
I have a menu added to a button.
buttons.push({
iconCls: 'fa fa-money',
text: 'Currency format',
menu: new Ext.menu.Menu(
{
items: [{
iconCls: 'fa fa-euro',
text: '1.000,00',
checked: true,
handler: function (btn) {
updateNumericFormat(btn);
}
},
{
iconCls: 'fa fa-dollar',
text: '1,000.00',
checked: false,
handler: function (btn) {
updateNumericFormat(btn);
}
}],
})
});
I would like to select only one item in the menu at the time. so if the first item is checked I want the other item to be unchecked. but I can't get it to work.
updateNumericFormat: function (btn) {
//uncheck the other button
}
Upvotes: 1
Views: 826
Reputation: 3300
updateNumericFormat: function (btn) {
btn.up().down('[name=euro]').setChecked(!btn.checked , true);
}
Full code,
Ext.create('Ext.menu.Menu', {
width: 100,
margin: '0 0 10 0',
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
iconCls: 'fa fa-euro',
text: '1.000,00',
checked: true,
name : 'euro',
handler: function (btn) {
btn.up().down('[name=dollar]').setChecked(!btn.checked , true);
}
},
{
iconCls: 'fa fa-dollar',
text: '1,000.00',
checked: false,
name: 'dollar',
handler: function (btn) {
btn.up().down('[name=euro]').setChecked(!btn.checked , true);
}
}]
});
Upvotes: 1
Reputation: 20244
What you are searching is the menucheckitem
's group
config, or maybe even a cycle
button.
Upvotes: 0