ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: hyh888 on October 15, 2021, 07:44:45 am
-
the json object structure of sava change is
list: {
addList: [{id: 1000, field1: value1, field2, value2,...}, {id: 1001, field1: value1, field1: value2}, ...],
deleteList: [{id: 10}, {id: 29},....],
updateList: [{id: 3, field1: value1, field2, value2,...}, {id: 7, field1: value1, field1: value2}, ...]
}
but the structure of our company is something like:
items: {
insert: [{id: 1000, field1: value1, field2, value2,...}, {id: 1001, field1: value1, field1: value2}, ...],
delete: [{id: 10}, {id: 29},....],
update: [{id: 3, field1: value1, field2, value2,...}, {id: 7, field1: value1, field1: value2}, ...]
}
If pqgrid has provided the function of json obj attribute customization function? Else I have to manually change json attribute in every crud page, it wil be a big trouble for me.
-
Before sending save data through remote call, items can be used instead of list and other gridChanges object keys can be named appropriately.
var gridChanges = grid.getChanges({ format: 'byVal' });
gridChanges.insert = gridChanges.addList;
delete gridChanges.addList;
//do same for other 2 keys.
https://paramquery.com/pro/demos/editing_batch
-
That mean I have to add some code form every page.
-
No, you have to make changes in saveChanges function only. Then keep this function in a separate file and call that function from every crud page.
-
Thank you very much.
-
if I change attribute of pqGrid Json like you showed, should I changed the following code in sample?
success: function (changes) {
//debugger;
grid.commit({ type: 'add', rows: changes.addList });
grid.commit({ type: 'update', rows: changes.updateList });
grid.commit({ type: 'delete', rows: changes.deleteList });
grid.history({ method: 'reset' });
},
-
yes that one too.