dtotwai720621
dtotwai720621
2015-10-20 09:07
浏览 92
已采纳

Ext.grid.editorgrid - 如何只发送第一行编辑数据?

I´m stuck with this component. Every time I call the update script for the editorgrid, the data sent to the PHP is the first edited row, but if I edit a second row the data sent is the first row edited and the second row edited. If I edit a third one the case is the same, the data sent to the PHP is the first, second, and third edited rows. Is there a way to only send the data from the row edited?

Here is my code:

var MCompetidoresGrid = new Ext.grid.EditorGridPanel({
        store       : MCompetidoresStore,
        columns     : [
            MCompetidoresSm,
            {header:'id',               dataIndex:'id',         sortable: true, width:30,   },
            {header:'Empresa',          dataIndex:'id_empresa', sortable: true, width:120,  },
            {header:'CIF',              dataIndex:'cif',        sortable: true, width:120,  editor:MCompetidorestextField},  //NUEVO CAMPO 12-03-2015
            {header:'Acronimo',         dataIndex:'codigo',     sortable: true,  width:60,  editor:MCompetidorestextField},
            {header:'Competidor',       dataIndex:'nombre',     sortable: true, width:200,  editor:MCompetidorestextField},
            {header:'Descripcion',      dataIndex:'descripcion',sortable: true,  width:320, editor:MCompetidorestextField}
        ],
        sm          : MCompetidoresSm,
        border      : false,
        stripeRows  : true,
        viewConfig:{
            markDirty:false
        }
});

var MCompetidoresStore = new Ext.data.Store({
        id          : "id",
        proxy       : MCompetidoresProxy,
        reader      : MCompetidoresReader,
        writer      : MCompetidoresWriter,
        autoSave    : true
});

var MCompetidoresWriter = new Ext.data.JsonWriter({
        encode          : true,
        writeAllFields  : false 
});

var MCompetidoresReader = new Ext.data.JsonReader({
        totalProperty   : 'total',
        successProperty : 'success',
        messageProperty : 'message',
        idProperty      : 'id',
        root            : 'data'
    },[
            {name: 'id'},
            {name: 'id_empresa'},
            {name: 'cif'},     
            {name: 'codigo'},
            {name: 'nombre'},
            {name: 'descripcion'},
    ]); 

var MCompetidoresProxy = new Ext.data.HttpProxy({
        api: {
            read    : "./Competenciaphp/MtoMaestro/getContacts.php"+"?"+"cliente="+despliegue,
            create  : "./Competenciaphp/MtoMaestro/createContact.php"+"?"+"cliente="+despliegue,
            update  : "./Competenciaphp/MtoMaestro/updateContact.php"+"?"+"cliente="+despliegue,                    
            destroy : "./Competenciaphp/MtoMaestro/destroyContact.php"+"?"+"cliente="+despliegue
        },
    }); 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongpo1203
    dongpo1203 2015-10-20 18:34
    已采纳

    I'm only familiar with local store but, if it's possible, I can suggest you to add a store.commitChanges() in your success event of the update.(something like we can do with an ajax call). Or add an update event in your store definition to do the commitChanges:

    var MCompetidoresStore = new Ext.data.Store({
            id          : "id",
            proxy       : MCompetidoresProxy,
            reader      : MCompetidoresReader,
            writer      : MCompetidoresWriter,
            autoSave    : true,
            listeners:
            { 
                update:function(){
                    this.commitChanges();
                }
            }
    });
    
    点赞 评论

相关推荐