Avoid Save on adding rows to Datatable

I'm adding a new row to a datatable by $$('table').add()
But when the add method is called the save request is send to the server. The id HAS to be generated on the server. How can i avoid the call of the save-url? I want to enter my values and send them to the server without saving a dummy first.

Comments

  • Hey @LaLaLand, could you please elaborate a little bit on this part?

    without saving a dummy first.

    I'm not entirely sure about the use case here. Are you trying to avoid calling the url specified in the save property altogether? Or do you want to wait for the server response first before adding the item locally?

    In the first case, it is possible to define a custom function in the save property, which means that you can customize the behaviour to your liking. Please note that the function should return either a promise of data or static data.

    In the second case, you can wait for the server response before doing anything on the client-side with the help of the waitSave method, which would look like this:

    $$("grid").waitSave(function(){
        this.add({
            rank:99,
            title:"",
            year:"2012",
            votes:"100"
        });
    })
    

    Here is an example of everything I've talked about: https://snippet.webix.com/t6jq76qc.

  • The use-case is, that the "add"-button will add a new row to the datagrid and the user has to enter the new values into the datatable.
    It don't know which values to save when adding the row and I don't want to save mess in my database to update it later.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!