【问题标题】:extjs: combobox typeahead does not work with querymode : remoteextjs:combobox typeahead 不适用于查询模式:远程
【发布时间】:2013-09-06 07:56:56
【问题描述】:

我有一个 extjs 组合框,其 queryMode 设置为 remote。 我还想要其中的typeAhead 功能。但是在这种情况下,提前输入不起作用。 即使在组合框中输入了一些文本,商店也会重新加载到原始数据。

这是我的代码:

var queryStore = Ext.create('Ext.data.Store', {
//autoLoad: true,
model: 'UserQuery',
proxy: {
    type: 'ajax',
    url: 'queryBuilder_getQueryList',
    extraParams: {
        tableId: this.title
    },
    reader: {
        type: 'json'
    }
},
listeners: {
    load: function () {
        var combo = Ext.getCmp('cmbQueryList');
        var lst = this.last();
        if (lst)combo.setValue(lst.data);
    }
}

});


var queryCombo = new Ext.form.ComboBox({
    width: 200,
    id: 'cmbQueryList',
    store: queryStore,
    valueField: 'queryID',
    displayField: 'queryName',
    typeAhead: true,
    forceSelection: true,
    emptyText: 'Select Query...',
    queryMode: 'remote',
    triggerAction: 'query',
    selectOnFocus: true,
    allowBlank: false,
    editable: true
 });

请建议我如何让 typeAhead 和 querymode remote 一起工作。

【问题讨论】:

  • 嗨 DarkKnightFan,你能解决这个问题吗?

标签: extjs extjs4 extjs4.1


【解决方案1】:

这段代码对我来说是软木塞。我猜你的商店属性自动加载是真的,所以当你要选择组合框时,它会转到服务器并重新加载数据。请删除 store auto load true 的属性。然后它的工作。

new Ext.form.ComboBox({  

    fieldLabel:'Apps',
    displayField: 'name',
    valueField: 'id',
    typeAhead: true,
    listWidth : 345,
    store: myStore(),
    forceSelection: true,
    triggerAction: 'all',
    mode:'remote',
    maxLength: 50,
    editable: false,
    anchor : '90%',
    selectOnFocus:true

 }),

【讨论】:

  • 我将 store 的 autoLoad 属性设置为 false。还是没有变化。每次我在组合框中输入文本时,都会重新加载存储并重置组合框(输入的文本会被清除)
  • 在原问题中添加了我的商店
【解决方案2】:

以下代码对我有用。我们必须将modequeryMode 都指定为local

var queryCombo = new Ext.form.ComboBox({
    width: 200,
    id: 'cmbQueryList',
    store: queryStore,
    valueField: 'queryID',
    displayField: 'queryName',
    emptyText: 'Select Query...',
    queryMode: 'local',
    mode: 'local'
 });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 2015-09-18
    • 2013-07-05
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 2020-01-20
    相关资源
    最近更新 更多