Documentation

getBranchIndex

gets index of the node in a specific branch

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

Parameters

ididtree node ID;
parentidID of the parent node.

Returns

numberindex of related tree node

See also

Example

tree = new webix.ui({
    view:"tree",
    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

Details

There is also the getIndexById method to get the node index but we don't suggest using it. 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.getParentView(sel); 
tree.add({ value:"New item"}, tree.data.getBranchIndex(parent, sel), parent);
Back to top