Skip to main content

save()

saves changes made in a data collection to the server side

save?: (url: string | IDataProxy) => void;

Parameters:

url: string | IDataProxy - the URL of a server side or DataProxy with the URL configured

Example

grid.data.save("http://userurl/");
//orgrid.data.save(new DataProxy({url:"http://userurl/"}));

Each time the user changes data of the component, the save() method will make an AJAX call and expect the remote URL to save data changes. The method will send one of the following requests to the backend:

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

Data saving is asynchronous, so you need to return a promise - the result of the saving operation. To do this, use the saveData property that returns a "promise" object:

var data = new DataCollection();data.save(loader);return data.saveData.then(function () {    // now your data is saved});

Use the isSaved method to know whether the changes are saved:

grid.data.saveData.then(function () {    console.log(grid.data.isSaved());});

Change log:

Before v7.2, the method sent the POST request to the backend on each change of data.
Starting from v7.2, depending on the user actions (editing, adding, or deleting of data), the method sends different requests (POST, PUT, or DELETE respectively) to the server.