当前位置: 代码迷 >> JavaScript >> ext combobox 怎么触发select事件
  详细解决方案

ext combobox 怎么触发select事件

热度:107   发布时间:2012-04-20 15:27:03.0
ext combobox 如何触发select事件
new Ext.form.ComboBox({
  id: 'usertype',
  hiddenName: "atype",
hiddenValue:"F",
  fieldLabel: '用户类型',
  typeAhead: true,
  triggerAction: 'all',
  lazyRender: false,
  value: '普通用户',
  width: 195,
  mode: 'local',
  store: new Ext.data.ArrayStore({
  id: 3,
  fields: ['value', 'displayText'],
  data: [
  ['F', '普通用户'],
  ['D', '认证用户'],
  ['R', 'Radius认证用户']
  ]
  }),
  valueField: 'value',
  displayField: 'displayText',
  listeners: {
  select: function (a, b, c) {
  var d = b.data.value;
  if (d == 'F') {
   
//do something  
  } else if (d == 'D') {
   
  //do somethins 2
  } else {
   
  //dom somethins 3

  }
  }
  }
  })

我用Ext.getCmp("usertype").setValue("认证用户"); 后,希望combobox会自动去 //do somethins 2,但是setValue后,不行?怎么触发select 事件?

------解决方案--------------------
fireEvent方法手动触发:

fireEvent( String eventName, Object... args ) : Boolean
Fires the specified event with the passed parameters (minus the event name).
Parameters:
eventName : String
args : Object...
Variable number of parameters are passed to handlers
Returns:
Boolean
returns false if any of the handlers return false otherwise it returns true
  相关解决方案