custom proxy documentation have not enough details

I’m trying to use webix with some none standard backend, so I need proxy object. But I’m not quite sure what is the right way.
I read http://docs.webix.com/desktop__server_proxy.html
there is sample code:

webix.proxy.myCustomName = {

    $proxy:true,
    prop1:value1,
    load:function(view, callback){
        webix.ajax(this.source, callback, view);
        },
    save:function(view, update, dp, callback){
        webix.ajax().post(url, data, callback);
    }
};

Also I read sample code http://docs.webix.com/samples/15_datatable/16_dyn_loading/07_dyn_proxy.html

load:function(view, callback, details){
    console.log(details);
    if (details){
        var data = [];
        for (var i=0; i<details.count; i++)
            data.push("x"+(i+1+details.from));

        webix.delay(function(){
            webix.ajax.$callback(view, callback, {
                pos:details.from,
                data:data
            });
        });
    } else {
        webix.ajax.$callback(view, callback, {
            total_count:100,
            data:["1","2","3","4","5"]
        });
    }
}

This code uses webix.ajax.$callback that’s not even from official documentation.
And I can’t find anywhere what parameters (and in what case) could save and load functions have

webix.ajax.$callback(view, callback, param) executes callback method for view passing param.

Parameters of proxy load method:

  • view - datastore where data are loaded
  • callback - functions that should be called on loading end. It’s an array that includes inner ‘loading end’ handlers and custom handlers.

Parameters of proxy save method:

  • view - datastore where data are saved
  • update- parameters of update operation
  • dp - data processor object
  • callback - a function that should be called after response received

Please check the following post about custom proxy. Possibly it’ll help:
http://forum.webix.com/discussion/comment/5461/#Comment_5461

Thanks. As I also read in http://forum.webix.com/discussion/4113/problem-with-the-webix-proxy/p1
when trying to save via proxy, script should call

callback.success();

is there any additional not documented functions or parameters (for save or load) that I should know about?

Hey @yurash,

Can you please format code properly? Just prefix each line with four spaces. It’s easiest if you do this in your editor by selecting the text and pressing Tab before pasting it here.

code line first
code line last

@dandv, I tried many times but this forum seems have it’s own ways about parsing code. Be my guest to try find what trips it

I’ve suggested using Discourse instead of Vanilla because the search sucks, but migrating forums is a pain in the ass.

Anyway, prefixing each code line with four spaces works:

    load: function(view, callback, details) {
        console.log(details);
        if (details){ 
            var data = []; 
            for (var i=0; i<details.count; i++)
                data.push("x"+(i+1+details.from));

            webix.delay(function(){
                webix.ajax.$callback(view, callback, {
                    pos:details.from,
                    data:data
                });
            });
        } else {
            webix.ajax.$callback(view, callback, {
                total_count:100,
                data:["1","2","3","4","5"]
            });
        }
    }

As I suggested in the other post, it’s easiest if you indent the text in your editor before pasting here.

Oh, yes I see, one more “tab” for the whole code block helped. I updated my other post, this one however is locked, I think forum gives only 24 hours for changing

I couldn’t agree more. Webix Proxy objects defenitely need much better documentation. Parsing data returned from a backend (e.g. from a spring rest API) is a very common task.

Some things I found out so far:

  • the proxy.load method can get a third parameter when using dynamic loading and paging.
  • the proxy.load method can return a plain array of rows for a datatable.
  • but when you use paging you must return the total_count for the pager to work => I am still trying to figour out how exactly…

And there are also webix DataDrivers which seem to be related…