How to expand a tree node automatically when an item is added ?

Hi,

I need a help on expanding tree nodes automatically when a new node is added or a item is added to one of the nodes.

Snippet: Code Snippet

Suppose, a new item is added at Skoda or a entire new noad with some leaf nodes got added to the tree. I want to make a function call from outside .js file to refresh that part of the tree without clicking the node manually.

How can I define the _expandTheNode function?
Any example of that would be very helpful.

you can use open within onAfterAdd handler
https://docs.webix.com/api__link__ui.tree_open.html
https://docs.webix.com/api__link__ui.tree_onafteradd_event.html

Hi intregal,
Thanks for pointing those links.

I need to do it little different way than done in those link due to my requirement.

Let’s say I have the tree object as below:

var t = $$(‘myTree’);

Now, by using _htmlmap below way I get all the node ids:

t._htmlmap

and below code gives me the textual name(content) of each node :
t._viewobj.textContent

Is there a way to get the mapping of each node text and their corresponding id ?

Thanks

tree object has its own data store, which you can use to iterate ids

var nodes = [];
$tree.data.each(function(row){
    nodes.push($tree.getItemNode(row.id));
})

Hi,
is there a way to disable automatically expand of a node when mouse over in a Drag and Drop operation? Thanks!

@ftedin
did you try onBeforeOpen handler?

  on:{
    onBeforeOpen: function(){
      if(webix.DragControl.getContext())
        return false
    }
  }

Yes, thanks, I found it after posting my question and forgot to add here the solution.
Thanks,