gostbuster
7 Sep 2012, 8:03 AM
I everyone, this seems to be simple but I don't succeed to get panel's data from a button. Showing code will try to explain :
Ext.define('MyPanel',{
extends:'Ext.Panel'
config:{
data:{ number:123456}
items:[
{xtype:'button', action="myaction"}
]
}
})
I'm working with MVC so I created a controler, and set my refs and controls on tap. So, I have the following function
onMyaction:function(button) { //yes it can take the button reference
var num = // I want here my number (123456)
}
I tried scope:this in order to do later a button.getData(); but this doesn't work.
the only solution I found is doing this :
onMyaction:function(button) { //yes it can take the button reference
var num =button.getParent().getData().number // This works but looks messy....
}
(The problem is, is that if I wanna put my button inside a toolbar, I would have to change my code and do a callParent().callParent() which looks crazy....:-?
Isn't messy (dirty) ? Does a better way exists to do what I wish ? I'm convinced that yes...but humm...I don't know..
Thank you very much in advance.
Ext.define('MyPanel',{
extends:'Ext.Panel'
config:{
data:{ number:123456}
items:[
{xtype:'button', action="myaction"}
]
}
})
I'm working with MVC so I created a controler, and set my refs and controls on tap. So, I have the following function
onMyaction:function(button) { //yes it can take the button reference
var num = // I want here my number (123456)
}
I tried scope:this in order to do later a button.getData(); but this doesn't work.
the only solution I found is doing this :
onMyaction:function(button) { //yes it can take the button reference
var num =button.getParent().getData().number // This works but looks messy....
}
(The problem is, is that if I wanna put my button inside a toolbar, I would have to change my code and do a callParent().callParent() which looks crazy....:-?
Isn't messy (dirty) ? Does a better way exists to do what I wish ? I'm convinced that yes...but humm...I don't know..
Thank you very much in advance.