Reputation: 21
Which property in Ext.form.Combobox is the field currently displayed in the ComboBox?
After a user selects something from the JsonStore and the value has been passed to combobox, the displayField is what shows up in the ComboBox's search field. I need to make a ComboBox where a user selects a certain object from JsonStore, but something totally unrelated is what displays in the ComboBox search field (this can't be done by changing any of the properties in the JsonStore record, because the string that is searched by the and the value that is passed in the end can not be different). I just need to override what is displayed in the combobox.
Upvotes: 0
Views: 3409
Reputation: 6760
What you may want to do is
aThirdField
(or whatever)In other words, the solution would be along the lines of -
Reference - Ext.form.ComboBox
Upvotes: 2
Reputation: 67892
You can make the displayed text different than the value.
Ext.define('BasicStoreModel', {
extend: 'Ext.data.Model',
fields : ['valueField', 'displayField']
});
var myStore = new Ext.data.SimpleStore({
model: 'BasicStoreModel',
data: [['value1','display1'], ['value2', 'display2']]
});
items: [...
{
fieldLabel: 'Label',
xtype: 'combo',
name: 'nameOfSelect',
editable: false,
store : myStore,
displayField: 'displayField',
valueField: 'valueField',
queryMode: 'local',
triggerAction: 'all',
}
The first two bits might seem like overkill, but I've wound up creating many SimpleStore instances which use BasicStoreModel. You should be able to extend JsonStore.
Upvotes: 0