首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Ext JS Library 2.0.2可编辑表格中如何显示combo的Text

2012-10-29 
Ext JS Library 2.0.2可编辑表格中怎么显示combo的Text做了个可编辑表格,但是表格中添加的combo显示的一直

Ext JS Library 2.0.2可编辑表格中怎么显示combo的Text
做了个可编辑表格,但是表格中添加的combo显示的一直是value,而非text,很是郁闷,今天读Ext的源码,发现如下解决办法:

渲染器comboRenderer定义如下:
Ext.util.Format.comboRenderer = function(combo){
    return function(value){
        var record = combo.findRecord(combo.valueField, value);
        return record ? record.get(combo.displayField) : combo.valueNotFoundText;
    }
}

在可编辑表格列模式中添加上面的渲染器即可。

var combo = new Ext.form.ComboBox({
                 typeAhead: true,
                 triggerAction: 'all',
                 // transform the data already specified in html
                 transform: 'accTypeSel',
                 lazyRender: true,
                 listClass: 'x-combo-list-small'
             });



{ header: "accType",dataIndex:"accType", width: 100,
   editor:combo,
        renderer: Ext.util.Format.comboRenderer(combo)
   } 1 楼 liuweifeng 2010-12-14   唉,看来Ext的协议让很多人不爽啊,没法用最新的版本……

热点排行