Remove typing cursor from combobox

孤街浪徒 提交于 2019-12-18 04:53:06

问题


I am using an ExtJS combobox. There is a typing cursor when focusing on the combobox. I tried to implement editable: false when creating the combobox, but it helped only for chrome.

Also tried clearListeners() function to see if this works on that cursor - didn't help, it still appears in FireFox and IE.

The other idea is to set disabled on the input field in combobox. When I did it manually, it helped.

But when I wrote the next

Ext.get('bu-encodingcount-combobox').select('input').set({disabled:'disabled'});

it didn't help - don't know, maybe the expression is wrong.


回答1:


The reason you see a cursor is because the combobox gets the focus, so the easiest way to handle this is to move the focus onto the drop down picker whenever the combo gets the focus.

Simply add this onFocus config to your combobox configuration:

// example combobox config
xtype: 'combo',
allowBlank: false,
forceSelection: true,
valueField:'id',
displayField:'name',
store: myStore,

// add this "onFocus" config
onFocus: function() {
    var me = this;

    if (!me.isExpanded) {
        me.expand()
    }
    me.getPicker().focus();
},

Also, I would only recommend doing this if this is a forceSelection: true combobox. It will ruin a users ability to type anything into the field.




回答2:


You can add the config,

editable:false

Then behaves as the normal Combo .




回答3:


Try -

For IE

combo.inputEl.set({disabled:'disabled'});

For Firefox -

combo.inputWrap.set({disabled:'disabled'});

For Chrome -

combo.inputCell.set({disabled:'disabled'});

This work fine.



来源:https://stackoverflow.com/questions/11758035/remove-typing-cursor-from-combobox

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