【问题标题】:Disable input in combobox ext js [duplicate]禁用组合框ext js中的输入[重复]
【发布时间】:2012-07-30 11:18:14
【问题描述】:

可能重复:
Remove typing cursor from combobox

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

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

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

【问题讨论】:

    标签: extjs combobox


    【解决方案1】:

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

    只需将此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 组合框,我只建议这样做。它会破坏用户在字段中输入任何内容的能力。

    【讨论】:

    • 天才!!有用!非常感谢!受了那么久,你救了我,谢谢!
    • 不幸的是,IE9 不支持,为什么会这样?
    • 我的错,它只出现在第二个。
    猜你喜欢
    • 2012-11-13
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    相关资源
    最近更新 更多