首页 > 解决方案 > 商店不在 ExtJs 中重新加载

问题描述

我正在处理一个需要绑定组合框但它没有重新加载最新数据的显示器。只有一次调用数据库,然后使用缓存中的现有存储。如何让它每次都从数据库重新加载(或者至少每次我们重新打开显示时)。下面是代码。

//store
Ext.define('NetworkStore', {
    extend: 'Ext.data.Store',
    alias: 'NetworkStore',
    fields: ['Id', 'value'],
    storeId: 'NetworkStore', 
    autoLoad: true,
    proxy: {
        type: 'ajax',
        useDefaultXhrHeader: false,
        actionMethods: { create: "POST", read: "GET", update: "POST", destroy: "POST" },
        headers: { 'Content-Type': 'application/x-www-form-urlencode' },
        limitParam: false,
        startParam: false,
        pageParam: false,
        extraParams: {
            Style: 1
        },
        url: 'url',
        reader: {
            type: 'json'
        }
    }
});

xtype: 'combo',
name: 'NetworkIDList',
store: Ext.create('NetworkStore').load({
                    params: {
                        Style: 3
                    }
                }),

标签: extjsstoreextjs6.5

解决方案


提供的官方文档lastQuery

    listeners: {
        beforequery: function (qe) {
            delete qe.combo.lastQuery;
        }
    }

这是完整的问题:

/**
 * @property {String} lastQuery
 * The value of the match string used to filter the store. Delete this property to force
 * a requery. Example use:
 *
 *     var combo = new Ext.form.field.ComboBox({
 *         ...
 *         queryMode: 'remote',
 *         listeners: {
 *             // delete the previous query in the beforequery event or set
 *             // combo.lastQuery = null (this will reload the store the next time it expands)
 *             beforequery: function(qe){
 *                 delete qe.combo.lastQuery;
 *             }
 *         }
 *     });
 *
 * To make sure the filter in the store is not cleared the first time the ComboBox trigger
 * is used configure the combo with `lastQuery=''`. Example use:
 *
 *     var combo = new Ext.form.field.ComboBox({
 *         ...
 *         queryMode: 'local',
 *         triggerAction: 'all',
 *         lastQuery: ''
 *     });
 */

推荐阅读