Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Extjs 4.2缓冲存储同步数据不工作_Javascript_Rest_Extjs_Extjs4.2 - Fatal编程技术网

Javascript Extjs 4.2缓冲存储同步数据不工作

Javascript Extjs 4.2缓冲存储同步数据不工作,javascript,rest,extjs,extjs4.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: {

以下是门店代码:

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
             }
     });
 }...
init:function(){
var me=这个;
自我控制({
“whatsnewlist”:{
whatsnewpinclick:函数(行索引){
var me=这个,
store=me.getWhatsNewsStore(),
记录=store.getAt(行索引);
record.set('isPin',!record.get('isPin');

store.sync();缓冲存储区不支持创建/编辑/删除操作。您可以在此处找到有关该问题的一些说明:

作为一种解决方法,您可以创建另一个“副本”存储,而无需缓冲(但如果需要,也可以使用分页)。在该存储上执行创建/删除/编辑操作,然后重新加载原始存储。 我还没试过这个,但我想它会管用的

或者,如果您只需要更新记录,您可以使用模型的save()函数

或者,您可以使用grid的“bufferedrenderer”插件代替缓冲存储: