gets index of the node in a specific branch

number getBranchIndex(id id, [id parent] );


ididtree node ID
parentidoptional, ID of the parent node


numberindex of related tree node


var tree = webix.ui({
    data: [
        { id:"branch1", value:"The Shawshank Redemption", data:[
            { id:"1.1", value:"Part 1" },
            { id:"1.2", value:"Part 2" }
var index  = tree.getBranchIndex("1.1"); // -> 0
var index1 = tree.getBranchIndex("1.2"); // -> 1


It's a common method that is inherited by all data-containing components from the DataStore class and not intended for using with tree-like data structures.

For exact node specifying, pass both node ID and parent node ID into the function:

var sel = tree.getSelectedId();
var parent = tree.getParentId(sel);
tree.add({ value:"New item"},, parent), parent);
See also
Back to top
If you have not checked yet, be sure to visit site of our main product Webix js framework and page of tree visualization javascript product.