_afterEditorEvent : function(obj){
var scope = this;
if (obj.value === ""){
return obj.value;
}
var bscStore = scope.comboxBsc.store;
var bscLabel;
for ( var i = 0; i < bscStore.data.length; i++) {
if (bscStore.data.items[i].data.value == obj.value) {
bscLabel= bscStore.data.items[i].data.name;
alert(bscLabel);
break;
}
}
//obj.record.data['RELATED_NEW_BSC_LABEL']=bscLabel;
scope.comboxBsc.setRawValue(bscLabel);
}
Ext editorGridPanel 中 有一列使用combobox ,选择后显示的是value 而不是name,我的combobox store是动态加载?每一行在编辑之前加载的。
上面是我用afterEditorEvent事件去设置显示的内容,但还是显示的是value ,求解???
终于找到解决方法了 :
_afterEditorEvent : function(obj){
var scope = this;
if (obj.value === ""){
return obj.value;
}
var bscStore = scope.comboxBsc.store;
var bscLabel;
for ( var i = 0; i < bscStore.data.length; i++) {
if (bscStore.data.items[i].data.value == obj.value) {
bscLabel= bscStore.data.items[i].data.name;
break;
}
}
var rd = obj.record;
rd.set('RELATED_NEW_BSC_LABEL' ,bscLabel); //设置combox 显示的name。
rd.set('RELATED_NEW_BSC_CUID' ,obj.value); //隐藏列显示combox 的value.
//rd.commit(); 加了commit ()修改后就不会标记红色提示。
}
第二种简单的方法:
this.useageStore = new Ext.data.ArrayStore({
fields : ["value", "label"],
data : [["T_LOGIC_DEVICE_MSCSERVER", "信令"],
["T_LOGIC_DEVICE_MGW", "媒体"],
["T_LOGIC_DEVICE_BSC", "复用"]]
});
this.useageCombo = new Ext.form.ComboBox ({
id : "USEAGE",
store : this.useageStore,
valueField : 'value',
displayField : 'label',
editable : true,
typeAhead : false,
width : 150,
forceSelection : true,
lazyRender :true,
allowBlank : false,
emptyText :'请选择',
mode : 'local',
triggerAction : 'all'
});
column :
{
header : "用途",
dataIndex : "USEAGE",
width : 160,
editor : this.useageCombo,
renderer : {fn:function (value){
for ( var i = 0; i < this.useageStore.data.length; i++) {
if ( this.useageStore.data.items[i].data.value == value) {
return this.useageStore.data.items[i].data.label;
}
}
return value;
} ,scope : this}