Ext表单中的combobox回填显示值问题

  缘由:在基于Ext构建的表单(form)中使用了Combobox组件,提交时使用hiddenName方式,后台可接收到所选的valueField值,实现保存功能。
问题:在修改页面中须将值回填到combobox中,但combobox显示的是valueField值而不是displayField值。解决的办法是在combobox的store中添加listener回填显示值。

解决问题所添加代码:
Js代码
  1. listeners: {    
  2.       load: function() {    
  3.            typeCombo.setValue(typeCombo.getValue());    
  4.       }    
  5. }  
 

完整代码:
         
Js代码
  1. var typeStore = new Ext.data.JsonStore({  
  2.         url: 'systemParmsProvider.do?type=DATA_TABLE_TYPE_LIST',  
  3.         fields: ['codeValue''codeLabel'],  
  4.         listeners: {    
  5.             load: function() {    
  6.                 typeCombo.setValue(typeCombo.getValue());    
  7.             }    
  8.         }    
  9.     });  
  10.     typeStore.setDefaultSort('codeValue');  
  11.           
  12.     var typeCombo = new Ext.form.ComboBox({  
  13.         store: typeStore,  
  14.         fieldLabel: '类型',  
  15.         displayField: 'codeLabel',  
  16.         valueField: 'codeValue',  
  17.         name: 'type',  
  18.         hiddenName: 'type',  
  19.         typeAhead: true,  
  20.         emptyText:'请选择数据表类型...',  
  21.         mode: 'local',  
  22.         triggerAction: 'all',  
  23.         selectOnFocus: true,  
  24.         editable: false,  
  25.         anchor:'95%'  
  26.     });  
  27.     typeStore.load();  


希望对大家能有所帮助,tks

你可能感兴趣的:(list,function,ext,table,url)