【问题标题】:EXTJS: How to clear "query" param from data store after a auto-complete query on combo boxEXTJS:如何在组合框上自动完成查询后从数据存储中清除“查询”参数
【发布时间】:2019-11-03 20:14:25
【问题描述】:

问题: 我有一个启用了自动完成功能的组合框(minchars = 2),还设置了 forceSelection = true。在我对组合框进行搜索之后,例如在组合框中输入“abc”,则列表将只显示包含字符串“abc”的记录。数据存储区发送到后端的查询字符串包含一个参数:“query:abc”。每次我调用“combo.getStore.reload()”时,请求中都会包含“query:abc”参数。因此,当我调用 combo.setValue("def") 时,它不会产生任何影响,因为组合的数据存储现在只包含其中包含“abc”的记录。 我试图通过调用从数据存储中清除“查询”参数: delete combo.lastQuery 或者从代理中删除额外的参数,从商店中删除过滤器,它们都不起作用。

测试代码在这里: 重现步骤:

  1. 设置数据存储查询远程服务器,服务器会返回
    • abc
    • abc1
    • 定义
    • jkl
    • ...
  2. 使用“设置组合值按钮”和“test_text”文本字段将组合值设置为“def”,组合值将被成功设置
  3. 在组合框上搜索,输入“abc”,则查询将只返回2条记录:
    • abc
    • abc1
  4. 选择其中任何一个
  5. 重复步骤 2 将组合值设置为“def”,该值将不会设置,因为数据存储不包含“def”。

问题:如何删除“查询”参数以恢复数据存储,以便查询所有值?

        {
            fieldLabel: 'Test Text',
            name: 'test_text',
            xtype: 'textfield',
            allowBlank: true
        },
        {
            xtype: 'button',
            text: 'set combo value',
            handler: function () {
                var text_field = this.up('form').down('textfield[name=test_text]');
                var combo_test = this.up('form').down('combo[name=test_combo]');
                combo_test.setValue(text_field.getValue());
            }
        },
        {
            xtype: 'button',
            text: 'reload store',
            handler: function () {
                var combo_test = this.up('form').down('combo[name=test_combo]');
                delete combo_test.lastQuery;
                combo_test.getStore().reload();
            }
        },
        {
            fieldLabel: 'Test Combo',
            name: "test_combo",
            xtype: 'combo',
            forceSelection: true,
            minChars: 2,
            allowBlank: false,
            store: Ext.create('Ext.data.Store', {
                proxy: {
                    type: 'ajax',
                    url: pcia.Globals.backendURL('/counterparty/broker/list_physical'),
                    reader: {
                        type: 'json',
                        rootProperty: 'records',
                        totalProperty: 'count'
                    }
                }
            }),
            displayField: 'name',
            valueField: 'name',
        }

【问题讨论】:

    标签: extjs combobox datastore


    【解决方案1】:

    试试

    combo_test.getStore().reload({params:{}});
    

    【讨论】:

    • @Leon 很高兴我能提供帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-12
    • 2013-01-24
    相关资源
    最近更新 更多