簡體   English   中英

Extjs網格列-值更改后組合顯示鍵而不是值

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

我有有動態列的網格。 當用戶單擊此列時,它將顯示商店返回的值的列表。一旦用戶選擇了任何值,我希望顯示字段顯示該值,而不是該值的數字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組合框displayValue

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM