Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description about toggleNodeOnClick and singleBranchExpand #4036

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions en/components/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@
- name: Tree
href: tree.md
new: false
updated: true
- name: List View
href: list.md
- name: Combo
Expand Down
30 changes: 29 additions & 1 deletion en/components/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,35 @@ When a node should render a link, the `IgxTreeNodeLink` directive should be adde
</igx-tree>
```
### Node Interactions
IgxTree provides the following API methods for node interactions:
[IgxTreeNodeComponent]({environment:angularApiUrl}/classes/igxtreenodecomponent.html) could be expanded or collapsed:
- by clicking on the node expand indicator *(default behavior)*.
- by clicking on the node if the `igx-tree` [toggleNodeOnClick]({environment:angularApiUrl}/classes/igxtreecomponent.html#toggleNodeOnClick) property is set to `true`.

```html
<igx-tree [toggleNodeOnClick]="true">
<igx-tree-node *ngFor="let node of data" [data]="node">
{{ node.text }}
<igx-tree-node *ngFor="let child of node.children" [data]="child">
{{ child.text }}
</igx-tree-node>
</igx-tree-node>
</igx-tree>
```

By default, multiple nodes could be expanded at the same time. In order to change this behavior and allow expanding only single branch at a time, the [singleBranchExpand]({environment:angularApiUrl}/classes/igxtreecomponent.html#singleBranchExpand) property could be enabled. This way when a node is expanded, all of the others already expanded branches in the same level will be collapsed.

```html
<igx-tree [singleBranchExpand]="true">
<igx-tree-node *ngFor="let node of data" [data]="node">
{{ node.text }}
<igx-tree-node *ngFor="let child of node.children" [data]="child">
{{ child.text }}
</igx-tree-node>
</igx-tree-node>
</igx-tree>
```

In addition, the IgxTree provides the following API methods for node interactions:
- [**expand**]({environment:angularApiUrl}/classes/igxtreenodecomponent.html#expand) - expands the node with animation.
- [**collapse**]({environment:angularApiUrl}/classes/igxtreenodecomponent.html#collapse) - collapses the node with animation.
- [**toggle**]({environment:angularApiUrl}/classes/igxtreenodecomponent.html#toggle) - toggles node expansion state with animation.
Expand Down
Loading