TreeList Selection
The TreeList component supports row and cell selection. When you select a row or a cell, they will be highlighted in the TreeList. This article provides an overview of the TreeList selection behavior and configuration:
- Enable row or cell selection
- Use single or multiple selection
- Access selected rows or cells
- Handle selection events
- Combine selection with other TreeList features
Enable Row or Cell Selection
You can configure the TreeList either for row or cell selection. See Row Selection Basics and Cell Selection Basics for more details and examples.
Use Single or Multiple Selection
You can configure the selection behavior by setting the TreeList SelectionMode
parameter to a member of the Telerik.Blazor.TreeListSelectionMode
enum. The TreeList supports the following selection modes:
-
None
(default)—Disables row and cell selection. -
Single
—Allows the user to select only one cell or row at a time. If the user attempts to select multiple cells or rows sequentially, only the most recent selection will take effect. -
Multiple
—Allows the user to select multiple rows or cells at a time.
Access Selected Rows or Cells
The TreeList exposes two parameters to get or set its selected rows and cells.
- Use the
SelectedItems
parameter (IEnumerable<T>
) to access the selected rows. - Use the
SelectedCells
parameter (IEnumerable<TreeListSelectedCellDescriptor>
) to access the selected cells.
Both parameters support two-way binding. You can also use the parameters to pre-select rows or cells for your users.
See Row Selection Basics and Cell Selection Basics for more details.
Events
You can respond to the user action of selecting a new item through the TreeList events:
- Use the
SelectedItemsChanged
event to respond to row selection. - Use the
SelectedCellsChanged
event to respond to cell selection.
Integration with Other TreeList Features
The selection feature behavior may differ when the TreeList configuration includes row or cell selection and other TreeList features. In these situations, certain limitations might arise, or additional adjustments may be required.
See Rows Selection and Other TreeList Features and Cells Selection and Other TreeList Features for more details.