【问题标题】:Filtering a combox in ExtJs过滤 ExtJs 中的组合框
【发布时间】:2012-09-21 18:19:44
【问题描述】:

我有一个 ExtJs 组合框。它的商店使用 JSON 加载(使用我的商店)。我想将所有值加载到存储中,然后使用组合文本字段中输入的文本过滤它们。

我不希望我的组合每次输入内容时都重新加载其存储。我怎样才能做到这一点? 还有其他事情,然后我第一次尝试从组合框中选择元素,它从服务器重新加载数据。 PS:我商店中的侦听器,用于从服务器中选择数据的第一个元素。 谢谢。

这是我的商店类:

Ext.define('KP.store.account.street', {
    extend: 'Ext.data.Store',
    model: 'KP.model.account.combo',
    autoLoad: true,

    proxy: {
        type: 'ajax',

        api: {

            read: '/account/combostreetdata'
        },
        reader: {
            type: 'json',
            root: 'combolist',
            successProperty: 'success',
            totalProperty: 'total'
        }
    },

    listeners: {
        'load': function (street_list) {
            var street_combo = Ext.getCmp('street');
            street_combo.select(street_list.getAt(0));
        }
    }
});

我的看法:

{
    id: 'street',
    xtype: 'combobox',
    width: 700,
    name: 'street',
    editable: true, 
    mode: 'local', 
    typeAhead: true, 
    emptyText: '?????',
    fieldLabel: '???',
    labelWidth: 120,
    size: 72,
    x: 20,
    y: 180,

    displayField: 'string_value',
    valueField: 'long_key',
    store: street_list
},

【问题讨论】:

    标签: javascript extjs4


    【解决方案1】:

    您有一个 ComboBox 配置错误。

    不是mode: 'local',,而是queryMode: 'local',

    我在我的连击中使用了这样的字段:

    queryMode: 'local',
    forceSelection: true,
    

    Typeahead 工作正常,在 typeahead 期间没有数据加载。

    【讨论】:

    • 谢谢,我的错。但是你知道为什么我第一次尝试从组合框中选择元素从服务器重新加载数据吗?
    • 嗯。尝试将proxy 配置选项放入模型中并将其从存储中删除。
    猜你喜欢
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多