admin管理员组

文章数量:1123043

is it possible for combobox getValue() return object ?

my combobox store field contain ID, Code, Description1, description2

i wish to return ID , Description1. description2.

is it possible for combobox getValue() return object ?

my combobox store field contain ID, Code, Description1, description2

i wish to return ID , Description1. description2.

Share Improve this question asked 3 hours ago Charles CandyCharles Candy 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Instead of using combobox.getValue() you might want to use combobox.getSelection().getData().

The selection model returns the full record.

If you have to use getValue(), you have to create a custom combobox. Remember, that this used in a lot of places out of the box, like the form.getValues(). Means: this needs more testing!!!

If you always want to use this, create an override.

/**
 * @return {Object|''}
 */
Ext.define('ValueCombobox', {
    extend: 'Ext.field.ComboBox',
    xtype : 'valuecombobox',

    getValue: function (combobox, a, b) {
        const value = this.callParent(),
              hasValue = !Ext.isEmpty(value),
              hasRecord = hasValue && this.getSelection();
              
        return hasRecord && hasRecord.getData() || '';
    }
});

本文标签: extjs combobox function getvalue() to return object contain multiple field valuesStack Overflow