【发布时间】:2013-03-12 17:58:25
【问题描述】:
我正在尝试获取此复选框的值
Ext.define('myRoot.myExtApp.myForm', {
extend: 'Ext.form.Panel',
layout: {
type: 'vbox',
align: 'stretch'
},
scope: this,
constructor: function() {
this.callParent(arguments);
this.myFieldSet = Ext.create('Ext.form.FieldSet', {
scope: this,
columnWidth: 0.5,
collapsible: false,
defaultType: 'textfield',
layout: {
type: 'hbox', align: 'stretch'
}
});
this.mySecondForm = Ext.create('myRoot.myExtApp.myForm2', {
scope: this,
listener: this,
margin: '1 3 0 0'
});
this.myCheckBox = Ext.create('Ext.form.Checkbox', {
scope: this,
//id: 'myCheckBox',
boxLabel: 'Active',
name: 'Active',
checked: true,
horizontal: true
});
this.myFieldSet.add(this.mySecondForm);
this.myFieldSet.add(this.myCheckBox);
this.add(this.myFieldSet);
}
});
如你所见,我有另一种形式
Ext.define('myRoot.myExtApp.myForm2', {
我有一个处理程序,它应该从“myForm”获取复选框的值
如何在不使用 Ext.getCmp 的情况下从 Form2 中获取复选框的值?我知道如果我这样做,我可以获得复选框的值
Ext.getCmp('myCheckBox').getValue();
但使用
this.myCheckBox.getValue();
给我未定义的错误。
更新 - 根据 Wared 的建议,我在 myForm2 中尝试了这个
this.temp=Ext.create('myRoot.myExtApp.myForm'), {});
var tempV = this.temp.myCheckBox.getValue();
我能够获得价值,但即使我取消选中该框,我也会获得相同的真实价值
【问题讨论】:
-
你的结构发布的不够多,我们需要看看它们是如何组合在一起的。
-
延伸 Evan 的回应——在
this.myCheckBox中无法分辨this的范围。 -
@EvanTrimboli,感谢您花时间查看我的帖子。请看我的更新。我已经用我的完整结构对其进行了编辑。
-
@Izhaki...嗨,Izhaki,请参阅我更新的帖子。这会有帮助吗?
-
你能创建一个jsFiddle吗?这真的很有帮助。
标签: javascript scope extjs4.1