问题
I have the below combobox code. Based on what user enters as first two characters I pull out some options through Ajax request and have user select one. The problem is right now I set it to send "fieldValue1.'|'.fieldValue2" values of the field with | separator in between. I want to know if there's a way to send fieldValue1 and fieldValue2 separately without requiring to do a separator?
xtype: 'combo',
autoLoad: true,
hideTrigger: true,
fieldLabel: 'Product',
displayField: 'Description',
valuefield: 'fieldValue1.'|'.fieldValue2',
name: 'product',
queryMode: 'remote',
queryParam: 'entry',
typeAhead: true,
minChar: 2,
store: {
fields: ['text', 'value'],
proxy: {
type: 'ajax',
url: TradeTransfer.Global.TradeTransferAPI + '/Requests/searchcommoditycodes',
reader: {
type: 'json'
}
},
sorters: [{
property: 'Exchange',
direction: 'ASC'
}]
}
回答1:
If the idea is to hold multiple properties of the selected record, one way is to have a extra property in the combobox and set it during the select event:
From https://www.sencha.com/forum/showthread.php?82033-Multiple-Value-binding-with-combo
var hidden = new Ext.form.Hidden({
name: 'userid'
});
var combo = new Ext.form.ComboBox({
...
displayField: 'username',
valueField: 'id',
hiddenName: 'id',
listeners: {
select: function(combo, record, index){
hidden.setValue(record.get('userid'));
}
}
});
But depending of your objective, you can use hiddenName property (https://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.field.ComboBox-cfg-hiddenName)
The name of an underlying hidden field which will be synchronized with the underlying value of the combo. This option is useful if the combo is part of a form element doing a regular form post. The hidden field will not be created unless a hiddenName is specified.
来源:https://stackoverflow.com/questions/52597157/sencha-extjs-submit-two-values