开发者

ExtJS: How to submit both: combobox value and text

开发者 https://www.devze.com 2023-02-20 02:49 出处:网络
ExtJS: How to submit both: combobox value an开发者_如何学JAVAd text using standardSubmit?To submit the valueField, you must specify a hiddenName to create a hidden input field to hold the value of the

ExtJS: How to submit both: combobox value an开发者_如何学JAVAd text using standardSubmit?


To submit the valueField, you must specify a hiddenName to create a hidden input field to hold the value of the valueField. You must also set submitValue to true

e.g.

var unitField = new Ext.form.ComboBox({
    id:'unitField',
    name: 'unit',
    submitValue : true,
    fieldLabel: 'Unit',
    store:unitStore,
    mode: 'remote',
    displayField: 'name',
    valueField: 'id',
    hiddenName : 'unitId',
    allowBlank: false,
    anchor:'95%',
    triggerAction: 'all'
});

So you get the value sent as unitId and the text as unit


If you want to submit two values, you will need two fields. If you want both fields to be controlled by one field, you should make one field hidden, and update it when the first is updated:

var hiddenField = new Ext.form.Hidden({
    name: 'comboDisplay'
});

var combo = new Ext.form.ComboBox({
    xtype: 'combo',
    // ...
    listeners: {
        select: function(combo, record) {
            hiddenField.setValue(record.data['display']);
        }
    }
});
0

精彩评论

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

关注公众号