Maison  >  Article  >  interface Web  >  ExtJS PropertyGrid中使用Combobox选择值问题_extjs

ExtJS PropertyGrid中使用Combobox选择值问题_extjs

WBOY
WBOYoriginal
2016-05-16 18:25:08741parcourir

问题描述:
  在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;
}

}
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn