Alter tree data after load

I am using a webix ui.tree to show details of an organization by loading the data from the server. Once the data is loaded I would like to add a new node(child) to the last branch in the tree in every single row. So for e.g. if every record is represented by 4 nodes then I would like to add data to 4th node of every record but I would like to do this once data is returned from the server because the new dynamic data would depend on another call to the server.

I tried doing it with 'onBeforeOpen' event but the problem is when I select parent without opening the children the selected count is incorrect as the data in the last child has not been updated.


  • edited February 2018

    You should loop through all the children of the copied node (eachChild method) and add them to the bottom treetable. The add method allows specifying the parent node. And use getBranch which returns dataset from some branch in the tree-like component:

    // "0" is a reserved ID of tree root
    $$("tree").data.eachChild("0", function(obj){
        if (obj.$count){
          var branch = this.getBranch(;
          var lastItem = branch[branch.length-1]
          this.add({".1", value:"New child of "+lastItem.value}, -1, );

    Here is an example:

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!

In this Discussion