waitSave

allows to catch the moment when a data operation was saved to the server

promise waitSave(function handler);
handlerfunctionone or several data operations
promisea promise that resolves if all operations were saved successfully and rejects if at least one failed

Example

webix.ui({
    view:"datatable",
    save:"/some/path",
    // ...other config
});
 
$$("grid").waitSave(function(){
    this.add({
        rank:99,
        title:"",
        year:"2012",
        votes:"100"
    });
}).then(function(obj){
    $$("grid").select(obj.id);
});

Details

this inside of the handler function points to the data component.

waitSave will work only if the component has a DataProcessor, i.e. if you set the way to save data to the server.

If the handler contains one data operation, the returned promise resolves with an object. For example, for an add operation, the object can contain the new server-side ID for the new record.

If the handler contains several data operations, the promise returns an array of objects for each data operation:

$$("grid").waitSave(function(){
    for (var i = 0; i < 3; i++){
        this.add({ rank:99, title:"", year:"2012", votes:"100" });
    }
}).then(function(arr){
    for (var i = 0; i < arr.length; i++){
        $$("grid").select(arr[i].id, i);
    }
});

waitSave stably works with if DataProcessor is enabled for the component and its autoupdate setting is not modified.

Back to top