New to Kendo UI for AngularStart a free 30-day trial

Selection

The TreeView allows the user to select a single node or multiple nodes.

Setup

To enable the selection, apply the built-in SelectDirective directive. It accepts the kendoTreeViewSelectable property, which enables you to control the built-in selection behavior, and both boolean and SelectableSettings parameters.

If you use a SelectableSettings parameter, the TreeView enables you to specify the following options:

  • enabled—Determines if the selection is initially enabled. The default value is true.
  • mode—Sets the SelectionMode of the selection. The default value is single.
Change Theme
Theme
Loading ...

Modes

The SelectDirective provides the default TreeView implementation for the single selection mode and the multiple selection mode of items.

Single Selection Mode

By default, the SelectDirective persists the selected item by utilizing its hierarchical index. To select a specific TreeView item by its hierarchical index, use the selectedKeys property.

Change Theme
Theme
Loading ...

You can also persist the single selection state by an item field—for example, a text field. To select a specific TreeView item by a unique field, use the selectBy property.

Change Theme
Theme
Loading ...

Multiple Selection Mode

To enable the multiple selection mode, use the kendoTreeViewSelectable property which sets the mode field to multiple.

By default, the SelectDirective persists the selected items by their hierarchical index. To display initially selected TreeView items, use the selectedKeys property and pass a list of hierarchical indices.

Change Theme
Theme
Loading ...

Similar to the single selection mode, you can also persist the multiple selection state by an item field—for example, a text field. To select TreeView items by a unique field, use the selectBy property.

Change Theme
Theme
Loading ...

Modifying the Selection

When the user modifies the selection, the TreeView emits the selectionChange event. It contains the following information:

  • index—The index of the affected TreeView item.
  • dataItem—The data item of the selected TreeView item.

You can also render a specific item as selected by collecting the provided information and using the isSelected property.

Change Theme
Theme
Loading ...