1

我有两个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
    }
});

this.cb1.getValue()用来获取选定的值,cb1但我在这里得到空白值。

谁能告诉我我在这里做错了什么。

4

1 回答 1

0

我认为组合 2 无法获得组合 1 的值,因为当您在 baseParams 中调用它的值时它没有加载。在您的情况下,我会推荐这种方法-

    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();
    }

这里,在第二个组合的选择渲染器上,第一个的值应该设置在combo2_val. 更准确的说,你也可以给combo 1设置默认值。不使用ID,直接使用变量cb1即可。

希望这应该给你一个方法。

于 2013-09-26T14:12:43.283 回答