ExtJS 4 组合框在表单绑定上显示值字段而不是显示字段

ExtJS 4 combobox shows valueField instead of displayField on form bind

本文关键字:字段 显示 绑定 组合 表单 ExtJS      更新时间:2023-09-26

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

        {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'}

商店已在网格中用于显示列类别

        { 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 "";
            }
        },

感谢您的帮助!

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