RealGrid2 Guide
Tree
Tree node information

Tree node information

RealGrid's TreeView provides various APIs to retrieve information about tree nodes. You can get the rowId of the ancestor, parent, child, and descendant node of a specific node and check the level.

TreeLocalProvider ancestors, parents, children, descendants

TreeLocalProivder There are functions that can check tree node information. The row information returned is rowId (dataRow), and the rowId is retrieved correctly even if the node to be retrieved is collapsed and not visible.

The value of rowIndicator in the demo below is displayed as rowId(dataRow) to make it easier to check the value.

function getAncestors() {
     const dataRow = treeView.getCurrent().dataRow;
     const ancestors = treeProvider.getAncestors(dataRow);
     alert(ancestors);
}
 
function getParent() {
     const dataRow = treeView.getCurrent().dataRow;
     const parent = treeProvider.getParent(dataRow);
     alert(parent);
}
 
function getChildren() {
     const dataRow = treeView.getCurrent().dataRow;
     const children = treeProvider.getChildren(dataRow);
     alert(children);
}
 
function getDescendants() {
     const dataRow = treeView.getCurrent().dataRow;
     const descendants = treeProvider.getDescendants(dataRow);
     alert(descendants);
}

TreeView ancestors, parents, children, descendants

TreeView has functions that allow you to check tree node information. The returned row information is itemIndex, and if the node to be retrieved is collapsed and is not visible, -1 is returned.

function getAncestors() {
     const itemIndex = treeView.getCurrent().itemIndex;
     const ancestors = treeView.getAncestors(itemIndex, true);
     alert(ancestors);
}
 
function getParent() {
     const itemIndex = treeView.getCurrent().itemIndex;
     const parent = treeView.getParent(itemIndex);
     alert(parent);
}
 
function getChildren() {
     const itemIndex = treeView.getCurrent().itemIndex;
     const children = treeView.getChildren(itemIndex);
     alert(children);
}
 
function getDescendants() {
     const itemIndex = treeView.getCurrent().itemIndex;
     const descendants = treeView.getDescendants(itemIndex);
     alert(descendants);
}