Extjs 4.2 grid refresh加载旧数据



我在Extjs 4.2中有一个网格,它的存储配置如下:

var userStore = Ext.create('Ext.data.JsonStore', {
model: 'User',
proxy: {
    type: 'ajax',
    api: {
        create: '/pwbench/form/products/fctrmgmt/data.json',
        read: '/pwbench/form/products/fctrmgmt/data.json',
        update: '/pwbench/form/products/fctrmgmt/data.json',
        destroy: '/pwbench/form/products/fctrmgmt/data.json'
    },
    reader: {
        type: 'json'
    },
    writer: {
        type: 'json'
    }
},
autoLoad: true
});

在网格中,单击save时,我配置了以下内容:

handler: function() {
        var recordsArray = new Array();
        var dataRecords = new Array();
        recordsArray = grid.getStore().data.items;
        for (var i = 0; i < recordsArray.length; i++) {
            console.log(recordsArray[i].data);
            dataRecords.push(Ext.encode(recordsArray[i].data));
        }
        console.log(dataRecords.length);
        Ext.Ajax.request({
            url: 'mainpage.jsp',
            params: {
                records: dataRecords
            },
            success: function(response){
                var text = response.responseText;
                console.log(text);
                userStore.sync();
                userStore.load();
            }
        });
    }

我有一个java类,它能够读取ajax请求发送的数据,然后我覆盖数据。Json文件,存储使用该文件获取数据。json文件被覆盖而没有任何问题,但问题是,当我在同步后调用userStore.load()时,它在进行任何更改之前显示旧数据。即使在刷新网格或刷新整个页面时,它也会显示旧数据,只有当我在Eclipse中刷新整个项目并重新加载页面时,它才会显示新的覆盖数据。

是否存在缓存问题?谁能告诉我有什么问题吗?

你应该在sync的成功回调中加载

userStore.sync({
        success: function() {
           userStore.load...

最新更新