Extjs 5 Combobox - Submitting Both Value And Text
I'm trying to get a simple combobox in ExtJS 5 to submit both the value and text of the selected element. From everything I've read it seems like this should work if I include the
Solution 1:
I would take a hidden field and on select of the combobox I would file the value of the hidden field.
xtype: 'form',
url: 'fakeurl',
scrollable: true,
defaultType: 'textfield',
defaults: {
fieldLabel: 'some field'
},
items: [{
name: 'myCombo',
//hiddenName: 'myComboId',
xtype: 'combo',
queryMode:'local',
valueField: 'id',
displayField: 'state',
store: {
model: 'KitchenSink.model.State',
data: [
[0, 'AL', 'Alabama', 'The Heart of Dixie'],
[1, 'AK', 'Alaska', 'The Land of the Midnight Sun'],
[2, 'AZ', 'Arizona', 'The Grand Canyon State']
]
},
listeners: {
select: function(combo, record, eOpts) {
var hiddenField = combo.up('form').down('textfield[name=myComboValue]');
hiddenField.setValue(record.get('abbr'));
}
}
}, {
name: 'myComboValue',
hidden: true,
hiddenName: 'myComboValue'
}],
buttons: [{
text:'Submit',
handler: function(btn){
btn.up('form').getForm().submit();
}
}]
Post a Comment for "Extjs 5 Combobox - Submitting Both Value And Text"