【问题标题】:ExtJS 4: Prevent combo box from opening autocomplete list on page (or form) loadExtJS 4:防止组合框在页面(或表单)加载时打开自动完成列表
【发布时间】:2012-10-25 08:33:04
【问题描述】:

当我的应用程序启动时,组合框正在拉出结果(扩展)并专注于表单中的组合框。应用程序启动时,如何防止自动聚焦和扩展此组合框?请注意,我尝试将配置“selectOnFocus”设置为 true 和 false,但没有任何效果。

                    width: 540,
                    labelAlign: 'right',
                    xtype: 'combo',
                    fieldLabel: 'Table',
                    emptyText: 'keyword search by table name...',
                    store: tableStore,
                    valueField: 'id',
                    displayField: 'value',
                    mode: 'remote',
                    name: 'table',
                    autoSelect: false,
                    selectOnFocus: true,
                    //shadow:true,
                    //forceSelection: true,
                    //triggerAction: 'all',
                    hideTrigger: true,
                    //multiSelect:true,
                    //typeAhead: true,
                    //minChars: 1,

                    listeners: {
                        change: function (obj, newValue, oldValue, eOpts) {
                            tableStore.proxy.extraParams.keyword = newValue;
                            tableStore.load();
                            this.expand();
                        }
                    }  // listeners

【问题讨论】:

    标签: extjs autocomplete combobox extjs4 onload


    【解决方案1】:

    问题是您的“更改”侦听器是在表单加载时触发的。

    你需要 this.expand() 调用吗?

    【讨论】:

    • 好的,我评论了“this.expand();”称呼。这样好一点。它不会在加载时展开,但现在它只会在输入至少 4 个字符后展开组合框。奇怪的是,在输入每个字符后都会调用该事件——我输入了一个警报,它调用了警报。我什至可以看到 Web 服务调用中的结果返回。为什么会这样?
    • 仅供参考:我的结果现在只有两条记录(选项)。我还没有尝试添加更多。这两个选项在第 5 个字符上有不同的字符(如果有帮助的话)。
    • 会不会是 store 加载和 expand 异步,一个比另一个好?
    • 存储加载总是异步的。当然,每次发生更改时都会触发更改事件,但是您可以对其进行缓冲:docs.sencha.com/ext-js/4-1/#!/api/…
    • 谢谢! 4 个字符是默认值。见:docs.sencha.com/ext-js/4-1/#!/api/…
    猜你喜欢
    • 2011-11-12
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2016-08-29
    • 2012-01-08
    • 1970-01-01
    • 2012-03-07
    • 2022-01-16
    相关资源
    最近更新 更多