PDA

View Full Version : Calling current instance method from tbar



sridhar.boganathan
21 Mar 2012, 5:59 AM
Hi All,

I have created my own class extend: 'Ext.form.Panel' with tbar (tool bar) with button. I am trying calling to call methods which in my class on click of those buttons. It raises error with "Object doesn't support this property or method".

I have tried with this.ownerCt.callSaveStudentDetails(); also. Same error



Ext.define('ogrdspoc.view.student.Details' ,{
extend: 'Ext.form.Panel',
alias : 'widget.studentdetails',
tbar: [
{
xtype: 'button',
text: 'Save',
handler: function(){
alert("Save Button--"+this.ownerCt);
this.ownerCt.callSaveStudentDetails();
}
},
{ xtype: 'tbseparator' },
{
xtype: 'button',
text: 'Retrieve',
handler: function(){
alert("Translations Button");
this.callRetreiveStudentDetails();
}
}
],
....
....
callSaveStudentDetails: function(){
console.log("callSaveStudentDetails...");
},
callRetreiveStudentDetails: function(){
console.log("callRetreiveStudentDetails...");
}
});

Loading of form, fields and values of the fields are working fine. I am using IE 8.

Please advice,
-Sridhar

vietits
21 Mar 2012, 6:48 AM
See my fix in red color:


Ext.define('ogrdspoc.view.student.Details' ,{
extend: 'Ext.form.Panel',
alias : 'widget.studentdetails',
tbar: [{
xtype: 'button',
text: 'Save',
handler: function(){
alert("Save Button--"+this.ownerCt);
// this.ownerCt.callSaveStudentDetails();
this.up('studentdetails').callSaveStudentDetails();
}
}, {
xtype: 'tbseparator'
}, {
xtype: 'button',
text: 'Retrieve',
handler: function(){
alert("Translations Button");
//this.callRetreiveStudentDetails();
this.up('studentdetails').callRetreiveStudentDetails();
}
}],
....
....
callSaveStudentDetails: function(){
console.log("callSaveStudentDetails...");
},
callRetreiveStudentDetails: function(){
console.log("callRetreiveStudentDetails...");
}
});

sridhar.boganathan
21 Mar 2012, 11:29 PM
It is working fine. Thanks.

-Sridhar