简体   繁体   English

Extjs中的行编辑插件问题

[英]Issue with Row Editing Plugin in Extjs

I have a fully working liveSearchGridPanel in ExtJs. 我在ExtJs中有一个完全可用的liveSearchGridPanel。 Error occurs when I edit any row. 编辑任何行时发生错误。 What Happens is that if the the updated row has to be resorted like in my case when I change the age of user (I am sorting on basis of age) row goes up or down in the grid, but the previous record remain there as well until I refresh the entire webpage manually. 发生的事情是,如果更新的行必须像我的情况一样,当我改变用户的年龄(我按年龄排序)时,行在网格中上升或下降,但之前的记录仍然存在直到我手动刷新整个网页。 Screenshot is below 屏幕截图如下

编辑后我的网页的屏幕截图

My proxy model is: 我的代理模型是:

Ext.define('proxymodel', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        persist: false
    }, {
        name: 'gender',
        type: 'auto'
    }, {
        name: 'name',
        type: 'auto'
    }, {
        name: 'age',
        type: 'int'
    }],

    identifier: 'sequential', // to generate -1, -2 etc on the client
    proxy: {
        type: 'rest',
        //format: 'json',
        //appendId: false,
        idParam: "id",
        //limitParam:"",
        //filterParam: "",
        //startParam:'',
        //pageParam:'',
        url: 'http://localhost:3000/posts',
        api: {
            read: 'http://localhost:3000/db',
            create: 'http://localhost:3000/posts',
            update: 'http://localhost:3000/posts',
            destroy: 'http://localhost:3000/posts'

        },

        headers: {
            'Content-Type': "application/json"
        },

        reader: {
            type: 'json',
            rootProperty: 'posts',

            totalProperty: 'total'

        },
        writer: {
            type: 'json'
        }
    }
});

In Application.js , I have defined row editing plugin as: Application.js ,我将行编辑插件定义为:

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
    listeners: {
        cancelEdit: function(rowEditing, context) {
            // Canceling editing of a locally added, unsaved record: remove it
            if (context.record.phantom) {
                store.remove(context.record);
            }
        },

        edit: function(editor, e) {
            // commit the changes right after editing finished
            e.record.commit();
        }
    }
});

And my store looks like: 我的商店看起来像:

Ext.define('Store', {
    extend: 'Ext.data.Store',
    storeId: 'peopleStore',
    pageSize: 500,

    //buffered: true,
    //leadingBufferZone: 300,

    pageSize: 5,

    autoLoad: {
        start: 0,
        limit: 5
    },
    autoSync: true,

    sorters: [{
        property: 'age',
        direction: 'ASC'
    }],

    groupField: 'gender'
});

Can anyone point out my mistake? 谁能指出我的错误?

I have tried to reload my store after editing in 'edit' function of rowEditing but it didn't work. 我在rowEditing 'edit'函数中编辑后尝试重新加载我的商店,但它没有用。

Thanks for your time. 谢谢你的时间。

As full answer by request: 作为要求的完整答案:

Have you tried Ext.data.StoreManager.lookup('peopleStore').reload() ? 你试过Ext.data.StoreManager.lookup('peopleStore').reload()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM