2017-08-03 42 views
1

我有一个菜单添加到按钮。如何只标记Extjs菜单中的一个菜单项目checked

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); 
       } 
      }], 

     }) 
    }); 

我想选择当时菜单中只有一个项目。所以如果第一个项目被选中,我希望其他项目不被选中。但我无法让它工作。

updateNumericFormat: function (btn) { 
    //uncheck the other button 
} 

回答

1

sencha fiddle

updateNumericFormat: function (btn) { 
     btn.up().down('[name=euro]').setChecked(!btn.checked , true); 
} 

的完整代码,

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); 
       } 
      }] 
     }); 
+0

超!现在它工作。 :] – Afflatus

相关问题