求高人解释一下ExtJs中this指针的的问题!!!

自定义类型的一个formpanel
showPersonFormPanel = Ext.extend(Ext.form.FormPanel,{
constructor:function(){
showPersonFormPanel.superclass.constructor.call(this,{
title:"formpanel表单",
renderTo:Ext.getBody(),
frame:true,
labelWidth:50,
width:304,
defaultType:'textfield',
defaults:{anchor:"95%"},
items:[{
fieldLabel:'姓名',
name:'name'
},{
fieldLabel:'年龄',
name:'age'
},{
fieldLabel:'性别',
name:'sex'
}],
buttons:[{
text:'修改记录',
listeners:{
"click":{
fn:function(){
//[color=red]测试this所引用的东西 ,传入this变量[/color]
//alert(this.title);输出“formpanel表单”
this.fireEvent("buttonClick",this);
},
//this代表的是全局的this 不是以前所引用的button的this
scope:this
}
}
}]
});
this.addEvents("buttonClick");
}
});
在下面是我的主文件调用



<br> var _grid = new showPersonGridPanel();<br> var _formPanel = new showPersonFormPanel();<br> _grid.on(&quot;rowselected&quot;,function(_record){<br> this.getForm().loadRecord(_record);<br> //此处的_formPanel代表的是上边的_formpanel,是可以在事件里所引用的this指针<br> },_formPanel);<br> _formPanel.buttons[0].on(&quot;click&quot;,function(_form){<br> [color=red] //alert(_form.title);无法访问到指定值 必须用下面的方法[/color]<br> [color=red] //alert(_form.ownerCt.ownerCt.title);[/color]<br> var _record = this.getSelectionModel().getSelected();<br> var _values = _form.ownerCt.ownerCt.getForm().getValues();<br> _record.set(&quot;name&quot;,_values.name);<br> _record.set(&quot;age&quot;,_values.age);<br> _record.set(&quot;sex&quot;,_values.sex);<br> _record.commit();<br> },_grid);<br>
我想问一下 为什么在主文件中不能直接通过_form.title得到指定值,我不是在前面通过this指针传入进了formpanel的对象吗?
为什么要通过两个_form.ownerCt.ownerCt.title才能得到指定的formpanel?谢谢回答,如果回答好,一定多多给分
(提醒一下 我用的是extjs 3.1.1)

你应该用on("buttonClick")而不是on("click")

用createDelegate来改变作用域:

[code="java"]_formPanel.buttons[0].on("click", function(_form){

}.createDelegate(this), _grid); [/code]