extjs 4 combobox , How to disabled tab and enter key

倾然丶 夕夏残阳落幕 提交于 2019-12-08 11:06:31

问题


I am using extjs 4.0.7. I want to disabled tab and Enter key event when user using Combobox. I have tried to use keyUp and KeyDown event. But I didn't get any alert for it.

Here is my code:

{
  xtype: 'combo',
  store: ds,
  id:'UserBO_SelectComponentId',
  displayField: 'displayName',
  valueField: 'userId',
  typeAhead: false,
  hideLabel: true,
  disabled: false,
  hideTrigger:true,
  multiSelect:true,
  delimiter: ";",
  anchor: '100%',
  triggerAction: 'all',
  listeners: {
     change: function( comboField, newValue, oldValue, eOpts ){
       selectUserCallBack2(newValue,'UserBO_SelectComponentId',comboField,oldValue);
     },
     select:function(comboField,oldValue){
        testRec(comboField,oldValue)
     },
     keypress:function(comboField,e){
        disabledKeysOnKeyup(comboField,e)
     }
  },
  listConfig: {
     loadingText: 'Searching...',
     enableKeyEvents: true,
     emptyText: 'No matching posts found.'
  }, 
  pageSize: 10 
}

Can anyone please suggest what is the problem here?


回答1:


The keyup, keydown and keypressed events only fire if enableKeyEvents is set to true. Default this is set to false, so you need to add enableKeyEvents:true to the combobox config. And then do special treatment for enter and tab key.




回答2:


You don't need to listen to key events and tab into that. What you want to do is set autoSelect to false. It's true by default. When set to false the user has to manually highlight an item before pressing the enter or tab key to select it (unless the value of typeAhead were true), or use the mouse to select a value.

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-cfg-autoSelect



来源:https://stackoverflow.com/questions/10630667/extjs-4-combobox-how-to-disabled-tab-and-enter-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!