2012-04-04 52 views
0

如果有一個網格,我想控制(從控制器)該網格的tbar中的一些按鈕。ExtJS4 MVC:如何按類別選擇按鈕

我可以找到按鈕,它有itemId屬性,但如何按類找到按鈕,以及什麼類需要使用(有baseCls,CLS和其他,他們不工作)?

這裏是我的控制器代碼:

Ext.define("Wtb.controller.Schedule",{ 
extend:'Ext.app.Controller', 

    refs:[{ 
     ref:'grid', 
     selector:'button' 
    }], 
init: function() { 

    this.control({ 
     'button#remove':{ 
      click:this.Remove 
     }, 
     'button#refresh':{ 
      click: this.Load 
     }, 
     'button#save':{ //Buttons with id works fine 
      click:this.Save 
     }, 
     'button.period':{ //It can't be found, because here is the class 
      click:this.changePeriod 
     } 
    }) 

這裏是按鈕的代碼片段:

{ //Button with ID 
    xtype:"button", 
    itemId:'refresh', 
    text:"Refresh" 
},'->',{ //Button with class. I need some buttons, like this. 
    xtype:"button", 
    text:"Period - day", 
    cls:'period', 
    value:'day' 
} 

如何通過類從控制器找到按鈕?

回答

4

退房的文檔爲ComponentQuery:http://docs.sencha.com/ext-js/4-0/#!/api/Ext.ComponentQuery

這應該讓你正確的按鈕:

'button[cls=period]' 
+0

CLS財產不能正常工作。我拿了componentCls並使用它。 – 2012-04-05 06:27:19

+0

它適合我。謝謝!! – 2016-07-07 21:45:09