开发者

ExtJs - Combobox and hidden fields

开发者 https://www.devze.com 2023-04-05 20:54 出处:网络
I have a problem with showing hidden field value. My code: var MyComboBox = Ext.extend(Ext.form.ComboBox, {

I have a problem with showing hidden field value. My code:

var MyComboBox = Ext.extend(Ext.form.ComboBox, {
initComponent : function() {
    Ext.apply(this, { 
        store           : Store ,

        displayField   : 'name',
        valueField     : 'id',

        typeAhead      : true,
        mode           : 'local',
        forceSelection : true,
        triggerAction  : 'all',
        selectOnFocus  : true
    });
    MyComboBox.superclass.initComponent.apply(this, arguments);
}
});


// Select event.
var combo1 = new MyComboBox({
    name        : 'combo1',
    applyTo     : 'combo1',
    hiddenName  : 'hcombo1',    // hidde field
    hiddenValue : 'id',

    listen开发者_开发技巧ers : {
        'select' : function() {
            combo2.setValue(combo1.getValue());
        }
    }
});

var combo2 = new MyComboBox({
    name      : 'combo2',
    applyTo   : 'combo2',
    listeners : {
        'select' : function() {
            alert(combo1.getRawValue()); // print hidden value (id of record)
        }
    }
}); 

I need value of hidden field with name - hcombo1. But code alert(combo1.getRawValue()) - print not ID, they print NAME. What I do wrong ? ExtJS 3.3.1


try change your listeners like this :

listeners : {
    'select' : function(combo) {
        combo2.setValue(combo.getValue());
    }
}

from docs, event "select" can passed 3 argument
select : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )

0

精彩评论

暂无评论...
验证码 换一张
取 消