extjs editor grid update rails

妖精的绣舞 提交于 2020-01-05 09:47:36

问题


i am trying to update records displayed in editor grid..but instead of updating same record, a new record gets inserted into the database...what am i missing??pllzz help..following is my JsonStore code :

Ext.data.Api.restActions = {
create  : 'POST',
read    : 'GET',
update  : 'PUT',
destroy : 'DELETE' };

ProdStore = Ext.extend(Ext.data.JsonStore, {
    constructor: function(cfg) {
        cfg = cfg || {};
        ProdStore.superclass.constructor.call(this, Ext.apply({
            storeId: 'ProdStore',
            id:'ProdStore',
            url: 'products.json',
            root: 'proddata',
            restful:true,
            idProperty:'id',
            successProperty:'success',
            autoLoad:true,
            autoSave:false,
            batch:true,
            writer: new Ext.data.JsonWriter({
            encode: false,
            listful: false,
            writeAllFields: false}),

            fields: [
                {   name:'customer_id'},{ name: 'prodnm'},
                {   name: 'qty'}, { name: 'rate' }, {   name: 'amt'}
            ]

        }, cfg));
    }
});
new ProdStore();

回答1:


The idProperty set on the store should be the field that represents unique rows in the database. Perhaps customer_id in this case?

If this does not fix the issue, I would have to see the back end code to see how the save is being handled.



来源:https://stackoverflow.com/questions/5716834/extjs-editor-grid-update-rails

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