Send Data in DataProcessor

edited February 24 in General

Hello.

I am using the DataProcessor but I run into the problem that I cannot send the data to the server.

I created my DataProcessor explicitly like this:

MyDataProcessor = new webix.DataProcessor({
         id:"tableDP",
         master:$$("bloque_agenda"),
         autoupdate:false,
         updateFromResponse:true,
         url:"my_url"
});

This process works fine for me when the autoupdate is active, but the point is that I need to send all the information at the same time, so I created a JS function to try to send the changes of my datatable to the server, but this causes me an error at the moment to execute the function (it is executed by pressing a button).

This is my JS function: webix.MyDataProcessor($$("bloque_agenda")).send();

I used the method webix.dp ($$ ()). send (); from the DataProcessor, I just substituted "dp" for my own DataProcessor, but obviously it doesn't work.

So I was wondering if there is a way to send the information of the datatable changes without using the automatic sending and creating the DataProcessor explicitly.

Thanks a lot!

Comments


  • It is possible to declare DataProcessor in two ways: separately, as you performed, and as a part of the master view (eg datatable) inside (save property)[https://docs.webix.com/desktop__serverside.html#datasaving].

          save:{
            autoupdate:false,
            url:"all->//docs.webix.com/samples/server/films_all",
            }
          }
    

    If you want to save all changes made by the user on demand, you should use (webix proxy)[https://docs.webix.com/desktop__server_proxy.html#saveall]. Using the method all() proxy will receive the updates tracked by DataProcessor till the moment it is called:

    webix.proxy.all = {
        $proxy:true,
        saveAll:function(view, updates, dp){
            //updates - the array of changed records
            return webix.ajax().post(this.source, { data:updates });
        }
    };
    

    After that, call send() method of component DataProcessor to push all the saved updates to the all() method of the above proxy
    Here is an example: https://snippet.webix.com/8xqts7gl
    Our backend isn't designed for this kind of saving, so to see the result, just check the request parameters.

  • Hello AlenaAlisava.

    In fact I tried to do it with the proxy, but it gives me an error when sending them with the send (); method, even in the snippet it shows the same error and the updates are never sent.

    Also use an implicit way, declaring the save property inside the datatable and using the send () method; and it worked fine for me, but using this form I cannot access the "attachEvent" events, specifically the "onAfterSync" event.

    Do you know any way to access these events when I declare the DataProcessor inside the Datatable?

  • edited February 25

    Hello, @CesarCTA
    It's not necessary to declare DataProcesser inside of the save() method, that is an option.
    In any case, Data Processor is always accessible via webix.dp( view )
    webix.dp($$("datatable1")) if any save() logic is given. Here is an example:
    https://snippet.webix.com/op05zvil
    In the example above you could change the way of declaring DataProcessor, the result stays the same.
    Concerning the error: Could you, please, specify the Error you are catching and how could we generate it.
    If you are speaking about the 404 (Not Found), as I mentioned before that is because our backend is not designed for this kind of saving. At the same time, this sent query holds all data about all changes, that supposed to be saved.

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!