javascript ExtJS 4 组合框在表单绑定上显示 valueField 而不是 displayField

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10404537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 09:46:14  来源:igfitidea点击:

ExtJS 4 combobox shows valueField instead of displayField on form bind

javascriptextjscomboboxextjs4

提问by Manuel

I got a extjs 4 combobox within a form bound to a model. I am binding data from grid to combo using form.loadRecord(record). The combobox is showing the valueField coming from the model assigned to the form instead of the displayField. The store of the combobox is preloaded. How can I achieve that the combobox shows the displayValue loading a record in the form?

我在绑定到模型的表单中得到了一个 extjs 4 组合框。我正在使用 form.loadRecord(record) 将数据从网格绑定到组合。组合框显示的 valueField 来自分配给表单的模型而不是 displayField。组合框的存储已预加载。如何实现组合框显示 displayValue 加载表单中的记录?

        {xtype:'combobox',
        fieldLabel: 'category',
        name: 'categorySelId',
        store: 'Categories',
        queryMode: 'local',
        displayField: 'label',
        valueField: 'id',
        anchor:'96%',
        loadMask: true,
        typeAhead: true,
        forceselection: true,
        valueNotFoundText: 'Nothing found'}

The store is already used in the grid to show the column category

store 已经在网格中使用,用于显示列类别

        { header: 'Category', dataIndex: 'categorySelectedId', flex:5,
            renderer: function(value,metaData,record) {
                if(value) {
                    var Categories = Ext.getStore('Categories');
                    var catRecord = Categories.findRecord('id', value);
                    return catRecord ? catRecord.get('label'): record.get('categorySelected');
                } else return "";
            }
        },

Thx for your help!

谢谢你的帮助!

回答by Manuel

The problem was that I have not had configured the correct types in the model. Setting the right type in the model solved the problem. Thx sha for helping!

问题是我没有在模型中配置正确的类型。在模型中设置正确的类型解决了这个问题。谢谢你的帮助!