RealGrid2 API
Class
TreeView

TreeView

TreeView class, a child class of GridBase.

Signature:

export declare class TreeView extends GridBase 

Extends : GridBase

Remarks

[Parent Class]

GridBase

Events

PropertyTypeDescription
onTreeItemChanged(tree: TreeView, itemIndex: number, rowId: number) => voidA callback notifying that the value of the TreeView has changed
onTreeItemCollapsed(tree: TreeView, itemIndex: number, rowId: number) => voidCallback notifying that the TreeView's item node is closed
onTreeItemCollapsing(tree: TreeView, itemIndex: number, rowId: number) => voidA callback that determines the collapse of the TreeView's item nodes
onTreeItemExpanded(tree: TreeView, itemIndex: number, rowId: number) => voidA callback notifying that the TreeView's item node has been expanded
onTreeItemExpanding(tree: TreeView, itemIndex: number, rowId: number) => booleanA callback that determines the expansion of item nodes in the TreeView

Properties

PropertyTypeDescription
treeOptionsTreeOptionsSetting model unique to TreeView

Methods

MethodTypeDescription
checkChildren(itemIndex, checked, recursive, visibleOnly, checkableOnly, checkEvent)checkChildren(itemIndex: number, checked: boolean, recursive: boolean, visibleOnly: boolean, checkableOnly: boolean, checkEvent?: boolean): void;Checks or unchecks the child rows of the input row.
collapse(itemIndex, recursive)collapse(itemIndex: number, recursive?: boolean): void;Collapse the row.
collapseAll()collapseAll(): void;Collapse all rows.
collapseModel(model, recursive)collapseModel(model: GridItem, recursive: boolean): void;Collapse an item (row).
expand(itemIndex, recursive, force, level)expand(itemIndex: number, recursive?: boolean, force?: boolean, level?: number): void;Expand the row.
expandAll(level, renewHasChildren)expandAll(level?: number, renewHasChildren?: boolean): void;Expand all rows.
expandModel(model, recursive, force, level)expandModel(model: GridItem, recursive?: boolean, force?: boolean, level?: number): void;Expand the item (row).
getAncestors(itemIndex, includeRoot)getAncestors(itemIndex: number, includeRoot?: boolean): number[];Returns the indices of ancestor rows.
getCheckedItems()getCheckedItems(): number[];Returns the index list of checked items as an array.
getCheckedRows(visibleOnly)getCheckedRows(visibleOnly: boolean): number[];Returns a list of indices of checked data rows.
getChildren(itemIndex)getChildren(itemIndex: number): number[];Returns the indices of child rows.
getDataSource()getDataSource(): LocalTreeDataProvider;Returns the DataProvider connected to the tree.
getDescendants(itemIndex)getDescendants(itemIndex: number): number[];Returns the indices of child rows.
getParent(itemIndex)getParent(itemIndex: number): number;Returns the index of the parent row.
getTreeOptions()getTreeOptions(): TreeOptions;Retrieves related setting information, such as tree grid selection display.
setTreeOptions(options)setTreeOptions(options: TreeOptions): void;Make settings related to tree view display and operation.

Events Desc

onTreeItemChanged

A callback notifying that the value of the TreeView has changed

Type - (tree: TreeView, itemIndex: number, rowId: number) => void

Remarks:

Occurs at commit() after the value has been changed.

[Parameter list]

tree - TreeView control

itemIndex - Index of the row whose value changed

rowId - Unique number of the row whose value was changed

Example:

treeView.onTreeItemChanged = function (tree, itemIndex, rowId) {
 console.log("TreeItem item changed:: " + itemIndex);
};

onTreeItemCollapsed

A callback notifying that the TreeView's item node has been depleted.

Type - (tree: TreeView, itemIndex: number, rowId: number) => void

Remarks:

[Parameter list]

tree - TreeView control

itemIndex - Index of the collapsed item row

rowId - Unique number of the collapsed row

Example:

treeView.onTreeItemCollapsed = function (tree, itemIndex, rowId) {
 console.log('Collapsed at: ' + itemIndex);
};

onTreeItemCollapse

A callback that determines the collapse of item nodes in the TreeView.

Type - (tree: TreeView, itemIndex: number, rowId: number) => void

Remarks:

[Parameter list]

tree - TreeView control

itemIndex - Index of the row you want to collapse

rowId - Unique number of the row you want to collapse

[Return value] - If false is returned, it will not be expanded.

Example:

treeView.onTreeItemCollapsing = function (tree, itemIndex, rowId) {
 return false;
};

onTreeItemExpanded

Callback notifying that the TreeView's item node has been expanded

Type - (tree: TreeView, itemIndex: number, rowId: number) => void

Remarks:

[Parameter list]

tree - TreeView control

itemIndex - index of expanded row

rowId - Unique number of the expanded row

Example:

treeView.onTreeItemExpanded = function (tree, itemIndex, rowId) {
 console.log('Expanded at: ' + itemIndex);
};

onTreeItemExpanding

A callback that determines the expansion of item nodes in the TreeView.

Type - (tree: TreeView, itemIndex: number, rowId: number) => boolean

Remarks:

[Parameter list]

tree - TreeView control

itemIndex - Index of the row to expand

rowId - Unique number of the row to be expanded

[Return value] - If false is returned, it will not be expanded.

Example:

treeView.onTreeItemExpanding = function (tree, itemIndex, rowId) {
 return false;
};

Properties Desc

treeOptions

Setting model unique to TreeView

Type - TreeOptions

Remarks:

TreeOptions Returns an object. You can get or set the properties of TreeOptions.

Example:

treeView.treeOptions.iconWidth = 20;

Method Desc

checkChildren

Checks or unchecks the child rows of the input row.

[Parameter List]

itemIndex - number

ItemModel index of parent row

checked - boolean

true: checked, false: off

recursive - boolean

Default: false, whether to expand descendant groups included in the group.

visibleOnly - boolean

If true, rows that collapse or are not visible during paging are excluded.

checkableOnly - boolean

If true, only checkable items are checked.

checkEvent - boolean

Default: true, whether onItemChecked() occurs.

[Return Value] - void

Example:

treeView.checkChildren(4, true, true, true, true);

collapse

Collapse the row.

[Parameter List]

itemIndex - number

Index of the row you want to collapse

recursive - boolean

Default: false, whether or not descendant groups included in the group are collapsed.

[Return Value] - void

Example:

tree.collapse(3);

collapseAll

Collapse all rows.

Example:

tree.collapseAll();

collapseModel

Collapse an item (row).

[Parameter List]

model - GridItem

The item model you want to collapse

recursive - boolean

Default: false, whether or not descendant groups included in the group are collapsed.

[Return Value] - void

Example:

let model = tree.getModel(4);
tree.collapseModel(model);

expand

Expand the row.

[Parameter List]

itemIndex - number

Index of the row you want to expand

recursive - boolean

Default: false, whether to expand descendant groups included in the group.

force - boolean

Default value: false, whether to expand descendants when recursive is true even if they are already expanded.

level - number

Default: 0, when 0 and recursive is true, expand all descendants.

[Return Value] - void

Remarks:

When recursive is true, if you specify a level, it expands to that level.

Example:

tree.expand(3);

expandAll

Expands all rows.

[Parameter List]

level - number

Default: 0, when 0 and recursive is true, expand all descendants.

[Return Value] - void

Remarks:

When recursive is true, if you specify a level, it expands to that level.

Example:

tree.expandAll();

expandModel

Expand the item (row).

[Parameter List]

model - GridItem

Model of the item you want to expand

recursive - boolean

Default: false, whether to expand descendant groups included in the group.

force - boolean

Default: false, whether to expand descendants when recursive is true even if already expanded

level - number

Default: 0, when 0 and recursive is true, expand all descendants.

[Return Value] - void

Remarks:

When recursive is true, if you specify a level, it expands to that level.

Example:

let model = tree.getModel(4);
tree.expandModel(model);

getAncestors

Returns the indices of ancestor rows.

[Parameter List]

itemIndex - number

the index of that row

includeRoot - boolean

Default value: true, true: Returns the result value including the index of the hidden top root row.

[return value] - number[]

Example:

let aIndexes = tree.getAncestors(3);

getCheckedItems

Returns the index list of checked items as an array.

Example:

let checkedItems = treeView.getCheckedItems();

getCheckedRows

Returns a list of indices of checked data rows.

[Parameter List]

visibleOnly - boolean

Default value: false, if entered as true, rows that collapse or are not visible during paging are excluded.

[return value] - number[]

Example:

let checkedRows = treeView.getCheckedRows(true);

getChildren

index of child rowsreturns the string.

[Parameter List]

itemIndex - number

index of parent row

[return value] - number[]

Example:

let cIndexes = tree.getChildren(3);

getDataSource

Returns the DataProvider connected to the tree.

Example:

let ds = treeView.getDataSource();

getDescendants

Returns the indices of child rows.

[Parameter List]

itemIndex - number

index of ancestor row

[return value] - number[]

Example:

let dIndexes = gridView.getDescendants(3);

getParent

Returns the index of the parent row.

[Parameter List]

itemIndex - number

index of child row

[return value] - number

Example:

let pIndex = tree.getParent(3);

getTreeOptions

Retrieves related setting information, such as tree grid selection display.

Example:

let treeOpts = tree.getTreeOptions();
treeOpts.lineVisible = false;
tree.setTreeOptions(treeOpts);

setTreeOptions

Make settings related to tree view display and operation.

[Parameter List]

options - TreeOptions

TreeOptions An object with the same content as the configuration model. You only need to change the properties you want to change.

[Return Value] - void

Remarks:

Use TreeOptions by specifying only the desired properties.

Example:

tree.setTreeOptions({lineVisible: false});