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)
}