ExtJs 4 Combobox missing config option hiddenName

断了今生、忘了曾经 提交于 2019-12-12 13:41:13

问题


I'm trying to create an ExtJs version 4 ComboBox that will post the valueField and not the displayValue. Prior version would be to set the 'hiddenName' option in the config of ComboBox, but I can't seem to find it in v 4 or something equivalent. Also, this is NOT in an ExtJs form panel. The combobox is being rendered inside a plain html form

//My Code

new Ext.form.ComboBox({
    renderTo: 'my_div',
    store: new Ext.data.SimpleStore({
        fields: ['value', 'name'],
        data: [['1', 'A'], ['2', 'B'], ['3', 'C']]
    }),
    name: 'letter',
    hiddenName: 'letter_id',
    hiddenValue : '0',
    displayField: 'name',
    valueField: 'value',
    mode: 'local'
});



//  The value of the form POST when I selected 'A'
"letter=A"

//  This is what I want
"letter=1"

回答1:


just for info.... Extjs team has improved the "configs" for every element.
And in combobox there is no longer hiddenName
have you ever read this? try to navigate to page 52, both will yield similar results...

var itemForm = Ext.create('Ext.form.FormPanel',{
    title: 'Simple Form',
    renderTo :Ext.getBody(),
    url :'test.php',
    items:[
        new Ext.form.ComboBox({
            store: new Ext.data.SimpleStore({
                fields: ['value', 'name'],
                data: [['1', 'A'], ['2', 'B'], ['3', 'C']]
            }),
            name: 'letter',
            displayField: 'name',
            valueField: 'value',
        })]
});

when i run this itemForm.getForm().submit() it send letter = 1..
maybe the error is somewhere else ..




回答2:


After stuck 8 hours i found problem my store respond from server contain "\r" or "\n" Just remove it it will work fine :)



来源:https://stackoverflow.com/questions/5720419/extjs-4-combobox-missing-config-option-hiddenname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!