javascript - Extjs 4.2 缓冲存储同步数据不起作用

标签 javascript rest extjs extjs4.2

这是商店代码:

Ext.define('NG.store.WhatsNews', {
    extend: 'NG.store.AbstractStore',
    model: 'NG.model.auxClasses.notifications.WhatsNew',
    alias: 'store.whatsnewstore',
    autoLoad:true,
    buffered: true,
    pageSize: 50,

    proxy: {
        type: 'rest',
        url: 'api/WhatsNew/'
    }
});

这是模型:

Ext.define('NG.model.auxClasses.notifications.WhatsNew', {
    extend: 'Ext.data.Model',
    idProperty:'iD',
    fields: [
        { name: 'iD', type: 'int' },
        { name: 'createDate', type: 'date', dateFormat: 'c' },
        { name: 'businessArchive', type: 'string' },
        { name: 'isPin', type: 'boolean' },
        { name: 'previousWhatsNewEvents' }

    ],

    // self association model
    associations: [{
        type: 'hasMany',
        model: 'auxClasses.notifications.WhatsNew',
        name: 'previousWhatsNewEvents',
        primaryKey: 'id',
        associationKey: 'previousWhatsNewEvents'
    }
});

这是来自 Controller 的代码:

init: function () {
     var me = this;

     me.control({
         'whatsnewlist': {
             whatsnewpinclick: function (rowIndex) {
                 var me = this,
                     store = me.getWhatsNewsStore(),
                     record = store.getAt(rowIndex);
                     record.set('isPin', !record.get('isPin'));
                     store.sync(); <<< THIS IS WHERE I FAILED
             }
     });
 }...

这是来自框架的错误:(在存储 getNewRecords 方法下失败)

enter image description here

似乎 Ext.data.PageMap 类没有定义 filterBy 方法。

这是一个已知问题吗?

有解决办法吗?

最佳答案

缓冲存储不支持创建/编辑/删除操作。您可以在这里找到有关该问题的一些描述: http://www.sencha.com/forum/showthread.php?251648-Ext-4.2.0-Beta-Object-object-Object-has-no-method-filterBy

作为解决方法,您可以创建另一个不带缓冲的“复制”存储(但如果需要,可以再次使用分页)。在该存储上执行创建/删除/编辑操作,然后重新加载原始存储。 我还没有尝试过,但我认为它会起作用。

或者,如果您只需要更新记录,可以使用模型的 save() 函数。我已经尝试过了,并且成功了。

或者您可以使用网格的“bufferedrenderer”插件来代替缓冲存储: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.plugin.BufferedRenderer

关于javascript - Extjs 4.2 缓冲存储同步数据不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19902349/

相关文章:

javascript - 使用 console.log() 调试 ExtJS 4

javascript - React 中的自定义 API 层

javascript - 多个 $http.get 请求,每个 JSON 文件由 HTML 中的 h1 分割

javascript - Gulp - 如何附加到目标而不是替换

Extjs 3.3.3 网格 - 禁用网格行

javascript - 在 html div 中呈现 ExtJS 4+ MVC 应用程序 - 如何做?

javascript - 在 HTTPS 页面中运行 HTTP AJAX 操作时出现 "Mixed content blocked"

mysql - Django 测试 django.db.utils.ProgrammingError : (1146, "Table ' DB.Table'不存在")

list - 如何使用rest API获取基于不同ID的记录?

javascript - SPA和SSO中无状态身份验证的性能(单点登录)