Question about saving a modified grid to server


#1

If some rows of a grid have been deleted and server will follow the change, code as below:

const selections = this.productGrid.selection.getCells().slice();
selections.forEach((item) => {
	this.productGrid.data.remove(item.row.id);
});

this.productGrid.data.save(URL);
this.productGrid.data.saveData.then(() => {
	this.loadList();
}).catch(err => {
});

The removed rows will be sent to server but the sent datas have no any differentia to the modified grid rows. I know I can set a “remove” flag to the deleted rows and “update” flag to updated rows but is there any built-in function of dhtmlx to distinguish them?


#2

The porblem is confirmed. We’ll try to erxtend that functionality in the future udpates.


#3

In the latest dhx.Suite update (7.2) we have updated the save() method:


Now the type of the request corresponds to the operation:

  • POST - after editing data of the component;
  • PUT - after adding new data into the component;
  • DELETE - after deleting data.

#4

Thank you for your job. It does work except one case. If I insert one row into a grid and change some datas for the new added row such as call addRowCss or modify the contents of one cell and then save to the server, the save() method will still POST the request. But if I just add a new row and then do nothing before call save(), a PUT request will be sent.


#5

The problem is confirmed. We’ll try to find a solution in the future.
for now, I can suggest you to save the data right after the row adding


#6

We have fixed your problem in the dhx.Suite 7.2.4 update.
Please, note, that since that update the request types changed a little bit:

  • POST - after adding new data into the component;
  • PUT - after editing data of the component;
  • DELETE - after deleting data.

I apologize for that inconvenience.