Reputation: 15
I have a multiselect combo. When a user select a value from combo then the value get displayed. Now I want add a string in the value choosed by the user and it should be displayed in combo not the selected value of the user
Upvotes: 0
Views: 76
Reputation: 4760
Seems like you are looking for the displayTpl config of your combobox (http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.form.field.ComboBox-cfg-displayTpl)
// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
]
});
// Create the combo box, attached to the states data store
Ext.create('Ext.form.field.ComboBox', {
fieldLabel: 'Choose State',
store: states,
multiSelect: true,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody(),
listeners: {
render: function(combo) {
combo.setDisplayTpl(
'{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}'
)
}
}
});
Fiddle: https://fiddle.sencha.com/#fiddle/1bqu
Upvotes: 1