2016-03-10 58 views
0

我有具有動態列的網格。當用戶點擊此列時,它會顯示商店返回值的列表。一旦用戶選擇了任何值,我希望displayfield顯示值而不顯示該值的數字ID(鍵)。Extjs Grid Column-在值更改後顯示鍵而不是值

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


             }          
            }         


       } 

回答

0

您需要在您的柱網添加渲染: 類似的東西

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

},

來源:Extjs4 combobox displayValue in grid