getBranchIndex

gets index of the node in a specific branch

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

Parameters

ididtree node ID
parentidoptional, ID of the parent node

Returns

numberindex of related tree node

Example

var files = webix.ui({
    view:"filemanager",
    data: [
        { id:"branch1", value:"Documents", date: 1420717913, type:"folder", data:[
            { id:"1.1", value:"Prices", type:"excel", date: 1420717913, size:"13" },
            { id:"1.2", value:"Products", type:"doc", date: 1420717913, size:"15" }
        ]}
    ]
});
 
var index  = files.getBranchIndex("1.1"); // -> 0
var index1 = files.getBranchIndex("1.2"); // -> 1

Details

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"}, tree.data.getBranchIndex(sel, parent), parent);
See also
Back to top