Extjs 4.2 buffered store sync data does not work

牧云@^-^@ 提交于 2019-12-07 22:58:28

问题


Here is the store code:

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/'
    }
});

Here is the model:

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'
    }
});

Here is the code from the 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
             }
     });
 }...

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

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

Is that a known issue?

Is there a workaround?


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/19902349/extjs-4-2-buffered-store-sync-data-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!