Reputation: 1203
I need to get value for id, do this:
Application.Exaple = Ext.extend(Ext.form.FormPanel, {
record_id : 0,
initComponent : function() {
Ext.apply(this, {
items: [
{
name : 'id',
id : 'id',
fieldLabel : 'ID',
readOnly : true,
hidden : true,
listeners : {
'render' : function() {
this.record_id = this.value;
}
}
},
{
name : 'pum',
id : 'pum',
handler : function() {
alert(this.record_id); // not work
}
but does not work. What am I doing wrong?
Upvotes: 0
Views: 251
Reputation: 3057
This looks like scope error.
you are trying to refer to the record while your current 'this' is the button.
You can do one of 2 things:
1) pass a scope to the handler like this:
{
name : 'pum',
id : 'pum',
scope: YOUR OBJECT HERE,
handler : function() {
alert(this.record_id); // not work
}
2) register the click event of the button from outside like this:
after you call the base form super class on your init method...
{
...
this.numBtn = this.items.itemAt(1);
this.numBtn.on('click',function(){YOUR LOGIC HERE},YOUR SCOPE HERE);
}
Hope this helps...
Upvotes: 2