1
votes

Problems: I have a combobox with autocomplete feature enabled (minchars = 2), also set the forceSelection = true. After I did a search on the combo box, e.g. input "abc" in the combo box, then the list will only show records contains string "abc". The query string that the datastore send to backend then contains a parameter: "query: abc". Every time I call "combo.getStore.reload()", the "query:abc" params will be included in the request. Thus when I call combo.setValue("def"), it wont have any effect because the datastore of the combo now only contains record that has "abc" in it. I tried to clear the "query" parameters from the data store by calling : delete combo.lastQuery or remove extra params from the proxy, remove filters from the store, none of them worked.

Test Code is here: reproduce steps:

  1. set up the data store to query remote server, the server will return
    • abc
    • abc1
    • def
    • ghi
    • jkl
    • ...
  2. set the combo value to "def" using the "set combo value button" and "test_text" text field, the combo value will be successfully set
  3. do an search on the combo box, enter "abc", thn the query will only return 2 records:
    • abc
    • abc1
  4. select anyone of them
  5. repeat step 2 to set combo value to "def", the value won't be set because data store doesn't contains "def".

Question: how to remove the "query" parameter to restore the data store so that it will query all values?

        {
            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',
        }
1

1 Answers

1
votes

Try

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