File Manager dynamic loading - branch loading via function

Re: setting up the file manager widget - When using dynamic loading using branch mode, is there a way to fulfill a branch event request via a function rather than specifying a server url as an attribute of the handlers property?

Hello,

You can try to define custom proxy:


var myProxy = {
    $proxy: true,
    load: function(view, callback, params){
          var id = params.source;
          var data = {...}; // json with branch data
          callback.success(data);
    }
};

webix.ui({
    view: "filemanager",
    id: "files",
    handlers:{
        branch:  myProxy,
        ...
    }
});

Thank you, That worked.

One problem I still have: I am using dynamic branch mode loading. When I load the page, the widget appends “#!/” followed by the top level id (“Files” in your examples) to the url. If the user clicks the refresh button, this results in a branch request for the ID “Files”, which was already fulfilled by the load request.

If the branch request is empty: - {}, the client hangs with the progress spinner. Is there any way to respond with an empty dataset, or a way to reject the branch request client side that avoids this?

BUMP on this one

From my side, if a branch request returns the following data, everything works smoothly.

{"parent":"name_of_parent_folder","data":[]}` 

Can you tune your server to respond with the above data, or provide a snippet with the error?

Helga,
I am using proxy because I need to set HTTP headers for authentication to dropbox. This is bad, because if there is an error, it tries to use fileManager.load() to recover.

Can I set the headers fileManager.load(), or how can I REMOVE ALL files and do another fileManger.parse(). If I can reload the TREE, I don’t need load again.

You can set HTTP headers globally, by catching the onBeforeAjax event that triggers when any Webix widget (including File Manager) issues an ajax request.

webix.attachEvent("onBeforeAjax", function( 
   mode, url, data, request, headers, files, promise
){
      headers["custom"]= "aaa-bbb-ccc";
});

Also, please hote that you can set custom headers for any request issued with webix.ajax separately as:

webix.ajax().headers({
   "custom":"aaa-bbb-ccc"
}).get(url); // or .post(url, params);

http://docs.webix.com/api__ajax_headers.html

As to removing all files, you can call the clearAll method to clear the FileManager data.