有个问题,向大家求教
我现在在用EXT做项目,里面有个列表是EDITORGRID,也就是可编辑表格,里面的编辑器都是COMBO下拉框,我现在通过后台获得数据显示到这个表格里的时候,显示的都是ID而不是名称,大家有什么方法可以让我的表格里显示的是名称而不是ID?因为如果手动的去增加修改数据的时候,是可以做到按照选择的下拉框选项显示名称,而实际在单元格中保存的是ID的效果的。
各位兄弟,给小弟指条明路吧,这问题结结实实的郁闷了我半个月了……小弟先谢过了 我的表格的每个字段的编辑器都是一个下拉框,下拉框的内容也都是从后台获取的动态数据 我是这样测试的,那数据有很多行,我每个字段也都绑定了renderer。当我把第一行所有的字段都编辑一遍以后,我对下面的每一行,只要编辑一个字段触发一下renderer,那么这一行所有的数据都会正确的显示出名称来 我现在猜测就是因为开始这个EDITORGRID的编辑器没初始化的原因,所以触发了renderer也获得不到值
如果能手动去初始化一下就好了。估计JACK当初是考虑效率的问题,所以做的触发的时候才实例化控件
我现在在用EXT做项目,里面有个列表是EDITORGRID,也就是可编辑表格,里面的编辑器都是COMBO下拉框,我现在通过后台获得数据显示到这个表格里的时候,显示的都是ID而不是名称,大家有什么方法可以让我的表格里显示的是名称而不是ID?因为如果手动的去增加修改数据的时候,是可以做到按照选择的下拉框选项显示名称,而实际在单元格中保存的是ID的效果的。
各位兄弟,给小弟指条明路吧,这问题结结实实的郁闷了我半个月了……小弟先谢过了 我的表格的每个字段的编辑器都是一个下拉框,下拉框的内容也都是从后台获取的动态数据 我是这样测试的,那数据有很多行,我每个字段也都绑定了renderer。当我把第一行所有的字段都编辑一遍以后,我对下面的每一行,只要编辑一个字段触发一下renderer,那么这一行所有的数据都会正确的显示出名称来 我现在猜测就是因为开始这个EDITORGRID的编辑器没初始化的原因,所以触发了renderer也获得不到值
如果能手动去初始化一下就好了。估计JACK当初是考虑效率的问题,所以做的触发的时候才实例化控件
坐沙发的兄弟,我的代码有点多,呵呵,所以只能这样描述了,既然这样,那么就贴一部分吧,劳驾各位给看看//出库表格
function StorageOutWinGrid(){
var xg = Ext.grid;
this.ds_factory = new Ext.data.JsonStore({
url: 'main.do?method=getFactoryList',
fields: ['value','label'],
autoLoad: true
});
this.ds_season = new Ext.data.JsonStore({
url: 'main.do?method=getSeasonList',
fields: ['value','label'],
autoLoad: true
});
this.ds_type = new Ext.data.JsonStore({
url: 'main.do?method=getTypeList',
fields: ['value','label'],
autoLoad: true
});
this.ds_code = new Ext.data.JsonStore({
url: 'main.do?method=getCodeList',
fields: ['value','label'],
autoLoad: true
});
this.ds_size = new Ext.data.JsonStore({
url: 'main.do?method=getSizeList',
fields: ['value','label'],
autoLoad: true
}); StorageOutWinGrid.prototype.sm = new xg.CheckboxSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(t, i, r){
StorageOutWinGrid.prototype.currentRow = r;
}
}
});
StorageOutWinGrid.prototype.cm = new xg.ColumnModel([StorageOutWinGrid.prototype.sm,
{header: '厂家', width: 15, dataIndex: 'socFactoryID', align:'center',
editor: new Ext.form.ComboBox({
//hiddenName:'userCom',
id:'SOFactoryCom',
fieldLabel: '厂家名称',
store: this.ds_factory,
displayField: 'label',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '选择厂家名称',
allowBlank:false,
editable: false,
anchor: "90%"
})},
{header: '服装大类', width: 20, dataIndex: 'socSeasonID', align:'center',
editor: new Ext.form.ComboBox({
id: 'SOSeasonCom',
fieldLabel: '服装大类',
store: this.ds_season,
displayField: 'label',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '选择服装大类',
allowBlank:false,
editable: false,
anchor: "90%"
})},
{header: '服装小类',width:20, dataIndex: 'socTypeID', align:'center',
editor: new Ext.form.ComboBox({
id:'SOTypeCom',
fieldLabel: '服装小类',
store: this.ds_type,
displayField: 'label',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '选择服装小类',
allowBlank:false,
editable: false,
anchor: "90%"
})},
{header: '号码', width: 15, dataIndex: 'socCodeID', align:'center',
editor: new Ext.form.ComboBox({
id: 'SOCodeCom',
fieldLabel: '服装号码',
store: this.ds_code,
displayField: 'label',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '选择服装型号',
allowBlank:false,
editable: false,
anchor: "90%"
})},
{header: '型号', width: 15, dataIndex: 'socSizeID', align:'center',
editor: new Ext.form.ComboBox({
id: 'SOSizeCom',
fieldLabel: '服装型号',
store: this.ds_size,
displayField: 'label',
valueField: 'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '选择服装型号',
allowBlank:false,
editable: false,
anchor: "90%"
})},
{header: '数量', width: 15, dataIndex: 'socCount', align:'center',
editor: new Ext.form.NumberField({
id: 'SOCountField',
allowBlank: false,
allowNegative: false,
maxValue: 100000
})}
]);
StorageOutWinGrid.prototype.cm.setRenderer(1,function(value,metadata,record,rowIndex,colIndex){return StorageOutWinGrid.prototype.value2label(value,colIndex);});
StorageOutWinGrid.prototype.cm.setRenderer(2,function(value,metadata,record,rowIndex,colIndex){return StorageOutWinGrid.prototype.value2label(value,colIndex);});
StorageOutWinGrid.prototype.cm.setRenderer(3,function(value,metadata,record,rowIndex,colIndex){return StorageOutWinGrid.prototype.value2label(value,colIndex);});
StorageOutWinGrid.prototype.cm.setRenderer(4,function(value,metadata,record,rowIndex,colIndex){return StorageOutWinGrid.prototype.value2label(value,colIndex);});
StorageOutWinGrid.prototype.cm.setRenderer(5,function(value,metadata,record,rowIndex,colIndex){return StorageOutWinGrid.prototype.value2label(value,colIndex);});
StorageOutWinGrid.prototype.store = new Ext.data.JsonStore({
url: 'storageout.do?method=getSODressList',
root: 'list',
fields: ['socGUID', 'socSOGUID', 'socFactoryID', 'socSeasonID', 'socTypeID', 'socCodeID', 'socSizeID', 'socCount']
});
StorageOutWinGrid.prototype.storageOutWinGrid = new xg.EditorGridPanel({
id:'SO-grid',
store: StorageOutWinGrid.prototype.store,
cm: StorageOutWinGrid.prototype.cm,
selModel: StorageOutWinGrid.prototype.sm,
clicksToEdit:1,
width:430,
height:300,
frame:false,
title:'出库服装明细',
//iconCls:'icon-grid',
viewConfig: {
forceFit:true
},
// inline toolbars
tbar:[{
text:'添加',
tooltip:'Add a new row',
iconCls:'iconAdd',
handler:StorageOutWinGrid.prototype.addRow
}, '-', {
text:'删除',
tooltip:'Remove the selected item',
iconCls:'iconRemove',
handler:StorageOutWinGrid.prototype.delRow
}]
});
return StorageOutWinGrid.prototype.storageOutWinGrid;
}StorageOutWinGrid.prototype.value2label = function (value,colIndex){
var id='';
if (colIndex==1){
id='SOFactoryCom';
}else if (colIndex==2){
id='SOSeasonCom';
}else if (colIndex==3){
id='SOTypeCom';
}else if (colIndex==4){
id='SOCodeCom';
}else if (colIndex==5){
id='SOSizeCom';
}
//alert(value);
//alert(Ext.getCmp(id).getRawValue());
if ((id=='')||(value==' ')){return;}
//Ext.getCmp(id).selectByValue(value,true);
//Ext.getCmp(id).setValue(value);
return Ext.getCmp(id).getRawValue();
}