Extjs 4.2缓冲存储同步数据不起作用 [英] Extjs 4.2 buffered store sync data does not work

查看:154
本文介绍了Extjs 4.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'
    }
});

这是控制器的代码:

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方法)

Here is the error from the framework: (it fails under the store getNewRecords method)

似乎Ext.data.PageMap类不包含filterBy方法的定义。

It seems that Ext.data.PageMap class does not hold a definition for filterBy method.

这是一个已知问题?

是否有解决方法?

推荐答案

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

Buffered store doesn't support create/edit/delete operations. Here you can find some description about that issue: http://www.sencha.com/forum/showthread.php?251648-Ext-4.2.0-Beta-Object-object-Object-has-no-method-filterBy

作为工作室,您可以创建另一个复制存储,而不需要缓冲(但是如果需要,则可以再次进行分页)。对该商店进行创建/删除/编辑操作,然后重新加载原始商店。
我没有尝试这个,但我认为它会工作。

As a workaroud you can create another 'copy' store without buffering (but again with paging if you need). do create/delete/edit operations on that store and then reload the original store. I haven't try this, but I think it will work.

或者,如果只需要更新记录,可以使用save该模型。我已经尝试过它,它的工作。

Or, if you need only update records, you can use save() function of the model. I've tried this and it worked.

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

Or instead of buffered store you can use 'bufferedrenderer' plugin of grid: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.plugin.BufferedRenderer

这篇关于Extjs 4.2缓冲存储同步数据不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆