2012-06-28 30 views
0

我正在創建一個分段按鈕,我需要根據分段按鈕的值修改應用程序。分段按鈕值setPressed不工作

{ 

        margin : '5 -5 0 25', 
        xtype: 'segmentedbutton', 
        allowMultiple: true, 
        height : 40, 
        id : 'fontStyleBtn', 
        items: [ 
          { 
           text: 'B', 
           width : 50, 
           style: 'background-color:red !important', 
           action : 'boldText' 
          }, 
         { 
          text: 'I', 
          width : 50, 
          style: 'font-size:14px;font-style:italic;background-color:#008c99', 
          action : 'italicText' 
         }, 
         { 
          text: 'U', 
          width : 50, 
          style: 'font-size:14px;background-color:#008c99;text-decoration:underline', 
          action : 'underlineText' 
         } 
        ]} 

當我第B挖掘,在我的應用程序中的文本加粗獲得。但我需要爲它設置一個值,以便下次點擊它時,我可以將文本重置爲正常。

Ext.getCmp('fontStyleBtn').getItems()[0].pressed = true; 

這似乎不適合我。

回答

0

Ext.getCmp('fontStyleBtn').getItems()[0]是否正確返回「B」按鈕?

如果是的話,試試這個:

Ext.getCmp('fontStyleBtn').getItems()[0].setPressed(true);

+0

號沒有關係的工作。 – Khush

+0

我把值放在一個數組中,並使用setPressedButtons()方法來設置值。爲我工作得很好。 – Khush