Author Topic: Customize attribute of save changes json object  (Read 1314 times)

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 102
    • View Profile
Customize attribute of save changes json object
« 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.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Customize attribute of save changes json object
« Reply #1 on: October 15, 2021, 03:30:39 pm »
[ Only Pro members may read this post. ]

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 102
    • View Profile
Re: Customize attribute of save changes json object
« Reply #2 on: October 15, 2021, 05:05:55 pm »
That mean I have to add some code form every page.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Customize attribute of save changes json object
« Reply #3 on: October 15, 2021, 06:33:10 pm »
[ Only Pro members may read this post. ]

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 102
    • View Profile
Re: Customize attribute of save changes json object
« Reply #4 on: October 16, 2021, 04:57:32 am »
Thank you very much.

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 102
    • View Profile
Re: Customize attribute of save changes json object
« Reply #5 on: October 18, 2021, 05:01:41 pm »
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' });
                    },
« Last Edit: October 18, 2021, 06:48:31 pm by hyh888 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: Customize attribute of save changes json object
« Reply #6 on: October 18, 2021, 09:27:33 pm »
[ Only Pro members may read this post. ]