2010-03-31 73 views
0

当我的用户通过RowEditor组合条目编辑网格和复选框是烦人ExtJS的RowEditor网格

1苹果 2橙色 3梨

例如与用户以上的组合将选择橙色再更新 - 网格现在而不是说橙色将显示数字2 - 我希望它成功编辑后显示橙色。对于我的组合

代码

 editor : { 
     allowBlank  : false, 
     displayField : 'team', 
     editable  : false, 
     emptyText  : 'Select Team', 
     forceSelection : true, 
     lazyRender  : true, 
     mode   : 'remote', 
     name   : 'team', 
     store   : storeTeam, 
     triggerAction : 'all', 
     valueField  : 'id', 
     xtype   : 'combo' 
    } 

我觉得我读,你可以在完整的行发送回插入或者我应该听网的更新,然后改变字段,但我需要一些指导什么是最好的

干杯

回答

1

尝试下面的代码。就像使用其他ExtJS网格列一样使用此列。

Ext.grid.FixedListColumn = Ext.extend(Ext.grid.Column, { 
    constructor: function(cfg){ 
    cfg.editor = new Ext.form.ComboBox(cfg.editor); 
    Ext.grid.ComboBoxColumn.superclass.constructor.call(this, cfg); 
    this.renderer = Ext.util.Format.comboRenderer(cfg.editor); 
    } 
}); 

Ext.grid.Column.types.fixedlistcolumn = Ext.grid.FixedListColumn; 

// Takes in a combobox and returns a renderer that looks up the displayField in 
// the store attached to the combo 
Ext.util.Format.comboRenderer = function(combo){ 
    return function(value){ 
     var record = combo.findRecord(combo.valueField, value); 
     return record ? record.get(combo.displayField) : combo.valueNotFoundText; 
    } 
} 

// Use this as the 'columns' parameter when creating your Grid 
var grid_columns = [ 
    {xtype:'fixedlistcolumn', 
    store: [[1,'Apple'],[2,'Orange']]}, 
    ... 
]; 
0

我希望这有助于...

可以渲染器定义添加到您的团队柱:

下面是例子真/假值是如何简单表示为是/否在GridPanel中:

renderer:function(val){ 
       if(val=="true" || val == true) { 
        return "Yes"; 
       } 
       else{ 
        return "No"; 
       } 
      }