IgxTreeComponent allows a developer to show a set of nodes in a hierarchical fashion.
- Igx Module
- IgxTreeModule
- Igx Theme
- igx-tree-theme
- Igx Keywords
- tree
- Igx Group
- Grids & Lists
Example
<igx-tree>
<igx-tree-node>
I am a parent node 1
<igx-tree-node>
I am a child node 1
</igx-tree-node>
...
</igx-tree-node>
...
</igx-tree> Constructors
Section titled "Constructors"IgxTreeComponent
new IgxTreeComponent(): IgxTreeComponent Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:315
Returns IgxTreeComponent
Properties
Section titled "Properties"activeNodeChanged
Section titled "activeNodeChanged"Emitted when the active node is changed.
activeNodeChanged: EventEmitter<IgxTreeNode<any>> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:264
Example
<igx-tree (activeNodeChanged)="activeNodeChanged($event)"></igx-tree> animationSettings
Section titled "animationSettings"Get/Set the animation settings that branches should use when expanding/collpasing.
<igx-tree [animationSettings]="customAnimationSettings">
</igx-tree>const animationSettings: ToggleAnimationSettings = {
openAnimation: growVerIn,
closeAnimation: growVerOut
};
this.tree.animationSettings = animationSettings; animationSettings: ToggleAnimationSettings Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:159
cssClass
Section titled "cssClass"cssClass: string = 'igx-tree' Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:89
expandIndicator
Section titled "expandIndicator"A custom template to be used for the expand indicator of nodes
<igx-tree>
<ng-template igxTreeExpandIndicator let-expanded>
<igx-icon>{{ expanded ? "close_fullscreen": "open_in_full"}}</igx-icon>
</ng-template>
</igx-tree> expandIndicator: TemplateRef<any> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:277
nodeCollapsed
Section titled "nodeCollapsed"Emitted when a node is collapsed, after it finishes
nodeCollapsed: EventEmitter<ITreeNodeToggledEventArgs> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:253
Example
<igx-tree (nodeCollapsed)="handleNodeCollapsed($event)">
</igx-tree>public handleNodeCollapsed(event: ITreeNodeToggledEventArgs) {
const collapsedNode: IgxTreeNode<any> = event.node;
console.log("Node is collapsed: ", collapsedNode.data);
} nodeCollapsing
Section titled "nodeCollapsing"Emitted when a node is collapsing, before it finishes
<igx-tree (nodeCollapsing)="handleNodeCollapsing($event)">
</igx-tree>public handleNodeCollapsing(event: ITreeNodeTogglingEventArgs) {
const collapsedNode: IgxTreeNode<any> = event.node;
if (collapsedNode.alwaysOpen) {
event.cancel = true;
}
} nodeCollapsing: EventEmitter<ITreeNodeTogglingEventArgs> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:236
nodeExpanded
Section titled "nodeExpanded"Emitted when a node is expanded, after it finishes
<igx-tree (nodeExpanded)="handleNodeExpanded($event)">
</igx-tree>public handleNodeExpanded(event: ITreeNodeToggledEventArgs) {
const expandedNode: IgxTreeNode<any> = event.node;
console.log("Node is expanded: ", expandedNode.data);
} nodeExpanded: EventEmitter<ITreeNodeToggledEventArgs> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:217
nodeExpanding
Section titled "nodeExpanding"Emitted when a node is expanding, before it finishes
<igx-tree (nodeExpanding)="handleNodeExpanding($event)">
</igx-tree>public handleNodeExpanding(event: ITreeNodeTogglingEventArgs) {
const expandedNode: IgxTreeNode<any> = event.node;
if (expandedNode.disabled) {
event.cancel = true;
}
} nodeExpanding: EventEmitter<ITreeNodeTogglingEventArgs> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:200
nodeSelection
Section titled "nodeSelection"Emitted when the node selection is changed through interaction
<igx-tree (nodeSelection)="handleNodeSelection($event)">
</igx-tree>public handleNodeSelection(event: ITreeNodeSelectionEvent) {
const newSelection: IgxTreeNode<any>[] = event.newSelection;
const added: IgxTreeNode<any>[] = event.added;
console.log("New selection will be: ", newSelection);
console.log("Added nodes: ", event.added);
} nodeSelection: EventEmitter<ITreeNodeSelectionEvent> Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:181
singleBranchExpand
Section titled "singleBranchExpand"Get/Set how the tree should handle branch expansion.
If set to true, only a single branch can be expanded at a time, collapsing all others
<igx-tree [singleBranchExpand]="true">
...
</igx-tree>const tree: IgxTree = this.tree;
this.tree.singleBranchExpand = false; singleBranchExpand: boolean = false Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:123
toggleNodeOnClick
Section titled "toggleNodeOnClick"Get/Set if nodes should be expanded/collapsed when clicking over them.
<igx-tree [toggleNodeOnClick]="true">
...
</igx-tree>const tree: IgxTree = this.tree;
this.tree.toggleNodeOnClick = false; toggleNodeOnClick: boolean = false Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:139
selection
Section titled "selection"selection: IgxTreeSelectionType Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:99, projects/igniteui-angular/tree/src/tree/tree.component.ts:103
Accessors
Section titled "Accessors"rootNodes
Section titled "rootNodes"Returns all root level nodes
const tree: IgxTree = this.tree;
const rootNodes: IgxTreeNodeComponent<any>[] = tree.rootNodes;get rootNodes(): IgxTreeNodeComponent<any>[] Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:294
Returns IgxTreeNodeComponent<any>[]
Methods
Section titled "Methods"collapseAll
Section titled "collapseAll"Collapses all of the passed nodes. If no nodes are passed, collapses ALL nodes
collapseAll(nodes: IgxTreeNode<any>[]): void Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:353
Parameters
- nodes:
IgxTreeNode<any>[]nodes to be collapsed
const targetNodes: IgxTreeNode<any> = this.tree.findNodes(true, (_data: any, node: IgxTreeNode<any>) => node.data.collapsible); tree.collapseAll(nodes);
Returns void
deselectAll
Section titled "deselectAll"Deselect all nodes if the nodes collection is empty. Otherwise, deselect the nodes in the nodes collection.
deselectAll(nodes: IgxTreeNodeComponent<any>[]): void Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:371
Parameters
- nodes:
IgxTreeNodeComponent<any>[]
Returns void
Example
const arr = [
this.tree.nodes.toArray()[0],
this.tree.nodes.toArray()[1]
];
this.tree.deselectAll(arr); expandAll
Section titled "expandAll"Expands all of the passed nodes. If no nodes are passed, expands ALL nodes
expandAll(nodes: IgxTreeNode<any>[]): void Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:337
Parameters
- nodes:
IgxTreeNode<any>[]nodes to be expanded
const targetNodes: IgxTreeNode<any> = this.tree.findNodes(true, (_data: any, node: IgxTreeNode<any>) => node.data.expandable); tree.expandAll(nodes);
Returns void
findNodes
Section titled "findNodes"Returns all of the nodes that match the passed searchTerm. Accepts a custom comparer function for evaluating the search term against the nodes.
findNodes(searchTerm: any, comparer: IgxTreeSearchResolver): IgxTreeNodeComponent<any>[] Defined in projects/igniteui-angular/tree/src/tree/tree.component.ts:411
Parameters
- searchTerm:
anyThe data of the searched node
- comparer:
IgxTreeSearchResolverA custom comparer function that evaluates the passed
searchTermagainst all nodes.