【问题标题】:Extjs 4.2 buffered store sync data does not workExtjs 4.2 缓冲存储同步数据不起作用
【发布时间】:2013-11-11 08:58:52
【问题描述】:

这是商店代码:

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

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

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

这是一个已知问题吗?

有解决办法吗?

【问题讨论】:

    标签: javascript rest extjs extjs4.2


    【解决方案1】:

    缓冲存储不支持创建/编辑/删除操作。在这里您可以找到有关该问题的一些说明: 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 2012-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多