如何在下次用户在ExtJS6中与其进行交互时使组合重新加载其商店?

时间:2016-02-11 00:36:25

标签: extjs extjs6

我有一个由ajax商店支持的简单组合框。我正在根据表单中的其他字段修改此商店的proxy.extraParams

问题是当用户在修改商店后按下向下箭头按钮时,之前的组合选项没有重置,就像组合不知道它的商店已被更改一样。有没有办法让组合在下次用户与之交互时重新加载其商店?

目前我每次修改商店参数时都会手动执行combo.getStore().load(),但这会导致不必要的ajax调用。也许用户甚至不再与该组合框进行交互,我只想在用户与组合字段交互时重新加载商店。

2 个答案:

答案 0 :(得分:3)

好的,您可以查看ExtJS combo code

// If they're using the same value as last time (and not being asked to query all), 
// and the filters don't need to be refreshed, just show the dropdown
if (me.queryCaching && !refreshFilters && queryPlan.query === me.lastQuery) {
    // The filter changing was done with events suppressed, so
    // refresh the picker DOM while hidden and it will layout on show.
    me.getPicker().refresh();
    me.expand();
}

// Otherwise filter or load the store
else {
    me.lastQuery = queryPlan.query;

    if (me.queryMode === 'local') {
        me.doLocalQuery(queryPlan);

    } else {
        me.doRemoteQuery(queryPlan);
    }
}

如果没有更改任何内容,queryCaching:false会导致不必要的通话,我猜你最好的选择是combo.lastQuery = null;

答案 1 :(得分:1)

每次用户展开组合框时,您都可以重新加载商店:

listeners: {
        expand: function() {
            this.getStore().load();
        }
    }