开发者

ExtJs - Combobox and hidden fields

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜