Extjs 网格列 - 组合在值更改后显示键而不是值

Extjs Grid Column- Combo displaying key instead of value after value change

本文关键字:显示 网格 组合 Extjs      更新时间:2023-09-26

>我有网格,其中有动态列。当用户单击此列时,它会显示商店返回的值列表。一旦他们用户选择任何值,我希望显示字段显示值而不是该值的数字 id(key)。

                .....................
                ......................
                plugins : [
                                Ext.create('Ext.grid.plugin.CellEditing', {
                                    clicksToEdit: 1,
                                    pluginId: 'Editor',
                                    listeners : {
                                        delay:1,
                                        scope: this                                               
                                    }
                                })
                                ],                                  


                     doAfterFilterRendered : function() {
                        for (var i = 0; i <Ext.getCmp('ReportGrid').gridColumns.length; i++) {
                            if (ColumnGridType ==  'COMBOBOX')// base on some condition i m trying to create combo box
                                {
                                Ext.getCmp('ReportGrid').gridColumns[i].editor=  {
                                    xtype: 'combobox',
                                    forceSelection: true,
                                    id : 'idCombo'
                                    editable: false,
                                    triggerAction: 'all',
                                    allowBlank: false,                                              
                                    store: me.getColumnStoreList("Country")// which return 2 dimentional array with key value                                            
                                }                                       
                            }                                   
                        }
                        Ext.getCmp('ReportGrid').getStore().load();
                        Ext.getCmp('ReportGrid').reconfigure(Ext.getCmp('ReportGrid').store, Ext.getCmp('ReportGrid').gridColumns);
                    },
                    ......................
                    ........................

我尝试按照事物显示值而不是键。

doAfterFilterRendered : function() {
                                for (var i = 0; i <Ext.getCmp('ReportGrid').gridColumns.length; i++) {
                                    if (ColumnGridType ==  'COMBOBOX')// base on some condition i m trying to create combo box
                                        {
                                        Ext.getCmp('ReportGrid').gridColumns[i].editor=  {
                                            xtype: 'combobox',
                                            forceSelection: true,
                                            id : 'idCombo'
                                            editable: false,
                                            triggerAction: 'all',
                                            allowBlank: false,                                              
                                            store: me.getColumnStoreList("Country") // which return 2 dimentional array with key value,
                                             **fields: ['key', 'value']}),
                                            valueField: 'key',
                                            displayField: 'value',**

                                        }                                       
                                    }                                   

                }

您需要在列网格中添加渲染器:类似的东西

renderer: function(val){
        index = me.getColumnStoreList("Country").findExact('key',val); 
        if (index != -1){
            rs = me.getColumnStoreList("Country").getAt(index).data; 
            return rs.value; 
        }

},

来源: Extjs4 组合框显示网格中的值