问题描述:
在PropertyGrid中使用Combobox来选择值时,得到的应该是displayField的值,但是在确认选择的时候却显示了valueField的值,例如,下拉选择性别,displayField分别为'男','女',对应的valueField分别为'0','1',本来选择应该显示中文描述,但是却显示成了0或者1这样的标识数据,这对用户来说应该不能接受的。
解决:
拦截Grid的beforepropertychange事件,设置好显示的值,之后返回false,阻止修改事件中的验证重置。
例如:
listeners: {
beforepropertychange: function (source, recordId, value, oldValue){
if (recordId == ' BRAND_NAME ' ){
var record = this .getStore().getById(recordId);
this .suspendEvents();
record.set( " value " , cmbBrandEdit.store.getAt(cmbBrandEdit.store.find( ' BRAND_ID ' , value)).get( ' BRAND_NAME ' ));
record.commit();
this .resumeEvents();
return false ;
}
}
}
beforepropertychange: function (source, recordId, value, oldValue){
if (recordId == ' BRAND_NAME ' ){
var record = this .getStore().getById(recordId);
this .suspendEvents();
record.set( " value " , cmbBrandEdit.store.getAt(cmbBrandEdit.store.find( ' BRAND_ID ' , value)).get( ' BRAND_NAME ' ));
record.commit();
this .resumeEvents();
return false ;
}
}
}