Ext.grid.editorgrid - 如何只发送编辑数据的第一行?
Ext.grid.editorgrid - How to only send the first row of edited data?
我坚持使用这个组件。每次我调用 editorgrid 的更新脚本时,发送到 PHP 的数据是第一行编辑的,但如果我编辑第二行,发送的数据是第一行编辑的和第二行编辑的。如果我编辑第三个,情况相同,发送到 PHP 的数据是第一、第二和第三个编辑行。有没有办法只发送编辑行的数据?
这是我的代码:
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
},
});
我只熟悉本地商店,但如果可能的话,我建议您在更新成功事件中添加一个 store.commitChanges()
。(就像我们可以使用 ajax 调用)。或者在您的商店定义中添加一个更新事件来执行 commitChanges:
var MCompetidoresStore = new Ext.data.Store({
id : "id",
proxy : MCompetidoresProxy,
reader : MCompetidoresReader,
writer : MCompetidoresWriter,
autoSave : true,
listeners:
{
update:function(){
this.commitChanges();
}
}
});
我坚持使用这个组件。每次我调用 editorgrid 的更新脚本时,发送到 PHP 的数据是第一行编辑的,但如果我编辑第二行,发送的数据是第一行编辑的和第二行编辑的。如果我编辑第三个,情况相同,发送到 PHP 的数据是第一、第二和第三个编辑行。有没有办法只发送编辑行的数据?
这是我的代码:
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
},
});
我只熟悉本地商店,但如果可能的话,我建议您在更新成功事件中添加一个 store.commitChanges()
。(就像我们可以使用 ajax 调用)。或者在您的商店定义中添加一个更新事件来执行 commitChanges:
var MCompetidoresStore = new Ext.data.Store({
id : "id",
proxy : MCompetidoresProxy,
reader : MCompetidoresReader,
writer : MCompetidoresWriter,
autoSave : true,
listeners:
{
update:function(){
this.commitChanges();
}
}
});