简体   繁体   中英

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

I have grid which have dynamic column. When the user clicks on this column, it display list of values from that the store returns.Once they user select any value, I would like the displayfield to show the valueand not the numeric id(key) of that value.

                .....................
                ......................
                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);
                    },
                    ......................
                    ........................

I tried following thing to display value instead of key.

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',**


                                        }                                       
                                    }                                   


                }

You need to add a renderer in your column grid: Something like that

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

},

Source: Extjs4 combobox displayValue in grid

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM