ExtJS 5组合框-提交值和文本 [英] ExtJS 5 combobox - submitting both value and text
问题描述
我试图在ExtJS 5中获得一个简单的组合框,以提交所选元素的值和文本。从我读过的所有内容来看,如果我为组合添加了hiddenName属性,这似乎应该可以工作,但无法同时提交它们。
这里是相关的组合框配置:
名称:'myCombo',
hiddenName:'myComboId',
SubmitValue:true,
xtype:'combo',
queryMode:'local',
valueField:'id',
displayField:'state',
这是所有设置完毕的jsFiddle:
感谢您的任何帮助。
我将选择一个隐藏字段,并在选择组合框时提交该隐藏字段的值。
xtype:'form',
url:'fakeurl',
scrollable:true,
defaultType:'textfield',
默认值: {
fieldLabel:某字段
},
项:[{
名称: myCombo,
// hiddenName: myComboId,
xtype:'combo',
queryMode:'local',
valueField:'id',
displayField:'state',
商店:{
模型: 'KitchenSink.model.State',
数据:[
[0,'AL','阿拉巴马州','迪克西之心'],
[1,'AK','阿拉斯加,午夜太阳之乡],
[2,'AZ','亚利桑那州','大峡谷州']
]
},
侦听器:{
选择:function(combo,record,eOpts){
var hiddenField = combo.up('form')。down('textfield [name = myComboValue]');
hiddenField.setValue(record.get(’abbr’));
}
}
},{
名称:'myComboValue',
隐藏:true,
hiddenName:'myComboValue'
}] ,
按钮:[{
文本:'Submit',
处理程序:function(btn){
btn.up('form')。getForm()。submit() ;
}
}]
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 hiddenName property for the combo but I cannot get it to submit both.
Here is the relevant combobox config:
name: 'myCombo',
hiddenName: 'myComboId',
submitValue: true,
xtype: 'combo',
queryMode:'local',
valueField: 'id',
displayField: 'state',
And here is a jsFiddle with this all set up: fiddle
If you look in firebug/chrome debugger at the request to my fake url when the form is submitted, you'll see that only 'myCombo' is submitted when I'm also expecting 'myComboId'.
Any help would be greatly appreciated, thanks.
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();
}
}]
这篇关于ExtJS 5组合框-提交值和文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!