Sencha ExtJS提交两个值 [英] Sencha ExtJS Submit two values
问题描述
我有下面的组合框代码.根据用户输入的前两个字符,我通过Ajax请求提取了一些选项,并让用户选择了一个.现在的问题是,我将其设置为使用|发送字段的"fieldValue1.'|'.fieldValue2"值.中间的分隔符.我想知道是否有一种方法可以单独发送fieldValue1和fieldValue2而不需要执行分隔符吗?
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'
}]
}
推荐答案
如果要保留所选记录的多个属性,一种方法是在组合框中具有一个额外的属性,并在select
事件期间对其进行设置:
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:
来自 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)
将与之同步的基础隐藏字段的名称 组合的基础价值.如果组合使用此选项很有用 是执行常规表单发布的表单元素的一部分.隐藏的领域 除非指定了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.
这篇关于Sencha ExtJS提交两个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!