PDA

View Full Version : MVS and find button by class.



biohazardo
4 Apr 2012, 5:52 AM
Hello.
I'm using MVC application type.

I want to control some buttons in grid toolbar from controller.



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':{
click:this.Save
},
'button.period':{ //It can't work
click:this.changePeriod
}
})
... some methods ...

It can find buttons by itemId, but I need create some same buttons to select period type, and take "value" property from button. But I can't create many buttons with one itemId. I need something like class.

I tried baseCls, cls properties of button, but they don't work. What I need to control that buttons? How to query that buttons?

Here is some button code snippets:



{ //That one work nice by id. I can user id here.
xtype:"button",
itemId:'refresh',
text:"Refresh"
},'->',{ //That one can't be find by class. Need some buttons, like this.
xtype:"button",
text:"Period - day",
cls:'period',
value:'day'
}

mitchellsimoens
4 Apr 2012, 11:42 AM
Tell me if I'm wrong but you are wanting to use a componentquery selector for an xtype with a property. So like if you have cls : 'myclass' set on the button you want to target the button with cls : 'myclass'?

You can do this:


'button[cls=myclass]'

biohazardo
4 Apr 2012, 10:26 PM
Something strange, but "cls" property is not working. Any other are fine. I decided to take componentCls for this purpose. Thanks.