Sencha extjs 属性范围
Sencha extjs attribute scope
目前我正在使用extjs 3.4,遇到了以下问题。我正在构造函数中创建 GridPanel,在设置此属性后,我设置了一个名为"bla"的变量名称,值为"test2",我提醒它以确保它已正确设置。这行得通!但是,当我的网格面板中按下按钮时,它无法再读取bla属性并说其"未定义"。
我跳过了代码中对问题没有意义的部分;)
请参阅下面的代码
Ext.define('SC.view.WorkOrderHourGrid' ,{
extend: 'Ext.grid.GridPanel',
bla:"test",
tbar: null,
store:null,
plugins:null,
//Methods
constructor:function(p_Store,config){
this.tbar = this.buildTbar();
this.bla = " test2";
this.store = p_Store;
//alerting bla attribute outputs test 2 !!
alert(this.bla);
var rowEditor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
this.plugins = [rowEditor];
SC.view.WorkOrderHourGrid.superclass.constructor.call(this,config);
},
buildTbar:function()
{
return [{
text: 'Toevoegen',
handler: function(){
tryOut();
},
//the button i was talking about
handler:this.onAdd
}];
},
onAdd:function(btn, ev)
{
//this outputs undefined !!!
alert(this.bla);
}
});
onAdd 函数中的范围是按钮。这就是为什么bla 是未定义的。
尝试像这样更改您的构建Tbar函数:
buildTbar:function()
{
return [{
text: 'Toevoegen',
scope: this,
//the button i was talking about
handler:this.onAdd
}];
},
我还没有测试过! :)
相关文章:
- HTML范围:动态设置值属性
- 如何从不同范围外的元素属性中获取求值表达式
- 无法使用编程加载的属性更新范围滑块.js
- 如何更改对 javascript 属性的调用的范围/上下文
- 显示范围输入的值"无法读取属性'值'“为空”;
- 如果指令包含在另一个指令中,我如何在隔离范围内添加双向数据绑定属性
- webGL,javascript:尝试访问属性1中超出范围的顶点
- 淘汰赛:can't从嵌套foreach访问父级范围的属性
- 范围属性可见性
- 角度写入嵌套范围属性
- Angular js 指令控制器访问范围属性,但返回未定义
- 如何在 HTML 中获取会话范围属性
- 当范围在角度可用时,如何在控制器中设置范围属性
- 在 HTML 模板中使用短划线绑定范围属性
- 使用一个指令从另一个独立作用域复制范围属性
- AngularJS:如何根据范围属性使链接不可单击
- 指令范围属性注入行为
- 如何从内部修改指令范围属性
- AngularJS指令-将属性值链接到范围属性
- AngularJs - 从多个ngRepeat引用相同的范围属性