禁用组合框ext js中的输入

时间:2012-08-01 14:20:37

标签: extjs combobox

  

可能重复:
  Remove typing cursor from combobox

要从组合框中删除键入光标,我需要禁用输入,它是组合框的一部分并且一直显示。问题是我尝试了不同的方式和表达方式并没有实现目标。 请问有人能解决我的问题吗?

Combobox id是bu-encodingcount-combobox。所需的输入是在bu-encodingcount-combobox> bu-encodingcount-combobox-bodyEl>输入中 我尝试了下一个表达式

var some = Ext.query('#bu-encodingcount-combobox-bodyEl > input');
Ext.get(some).set({disabled:'disabled'});

1 个答案:

答案 0 :(得分:4)

您看到光标的原因是因为组合框获得了焦点,因此处理此问题的最简单方法是在组合获得焦点时将焦点移动到下拉选取器上。

只需将此onFocus配置添加到您的组合框配置中:

// 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();
},

另外,如果这是一个forceSelection: true组合框,我只建议这样做。它会破坏用户在现场输入任何内容的能力。

相关问题