简体   繁体   English

如何将选定的extjs组合值设置为另一个组合框

[英]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.

相关问题 如何根据datagridview中另一个组合框中的选定值填充datagridview中的组合框? - How to populate a combo box in a datagridview as per the selected values in another combobox in datagridview? 检查组合框选择的值字符串,并在另一个组合框中更改selexctedIndex - check combo-box selected value string and change selexctedIndex in another combo box 如何在DropDownList编辑模板上设置选定的值? - How to set selected value on DropDownList edit template? C#-从组合框中检索选定的值 - C# - retrieve the selected value from a combobox 如何使WPF组合框记住以前选择的值,即使将其更改为新值也是如此? - How to make wpf combobox remember the previous selected value even if change it to new value? 将选定值CardNumber在form1上的组合框转换为form2 - Taking the selected value CardNumber a combo box on form1 to form2 如何根据组合框中选择的选项转换为表单? - How to shift to forms based on option selected in combobox? 如何使用组合键在解决方案资源管理器中选择的项目上运行调试? - How to run debug on a project selected in Solution Explorer with a key combo? 将组合框的值检索到另一个组合框。 - retrieving the value of the combox to another combobox., 当我选择 combobox1 最后一个值时,combobox2 最后一个值将被自动选择 - When i select the combobox1 last value the combobox2 last value will be automatically selected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM