[英]How to set selected extjs combo value to another combobox
I have two Extjs Comboboxes
我有两个Extjs Comboboxes
var cb1 = new Ext.form.ComboBox({
fieldLabel: 'Combobox1',
width: 100,
listeners:{
scope: this,
'select': this.reset
}
});
var cb2 = new Ext.form.ComboBox({
fieldLabel: 'Combobox2',
width: 100,
baseParams: { loadInitial: true, cb1Val: this.cb1.getValue() } // Here I want to get selected value of cb1
listeners:{
scope: this,
'select': this.reset
}
});
I am using this.cb1.getValue()
to get selected value of cb1
but I am getting blank value here. 我正在使用this.cb1.getValue()
获取cb1
选定值,但是我在这里得到空白值。
Can anyone tell me what I am doing wrong here. 谁能告诉我我在做什么错。
I think combo 2 is not able to get value of combo 1 as its not loaded while you are calling its value in baseParams. 我认为组合2无法获得组合1的值,因为您在baseParams中调用其值时未加载组合1。 I would recommend this approach in your case - 我会根据您的情况推荐这种方法-
var cb1 = new Ext.form.ComboBox({
fieldLabel: 'Combobox1',
width: 100,
**id : "combo_1",** // ID property added
listeners:{
scope: this,
'select': this.reset
} });
// Previous code
...
listeners : {
select : function(combo, rec, rind) {
var combo2_val = Ext.getCmp("id_of_combo_1").getValue();
}
Here, on the select renderer of second combo, the value of first should be set in combo2_val
. 在此,在第二个组合的选择渲染器上,应该在combo2_val
设置第一个的值。 To be more precise, you can also set default value for combo 1. Instead of using ID, you can directly use variable cb1 directly. 更精确地说,您还可以为组合1设置默认值。您可以直接使用变量cb1来代替ID,而不必使用ID。
Hope this should give you a way. 希望这能给您一个方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.