DxTreeList.DeselectRow(Int32) Method
Deselects a row with the specified visible index.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
#Declaration
public void DeselectRow(
int visibleIndex
)
#Parameters
Name | Type | Description |
---|---|---|
visible |
Int32 | The row’s visible index. |
#Remarks
The following methods allow you to manage TreeList selection:
- SelectRow (
DeselectRow
) - SelectRows (DeselectRows)
- SelectDataItem (DeselectDataItem)
- SelectDataItems (DeselectDataItems)
- SelectAllOnPage (DeselectAllOnPage)
- SelectAllAsync (DeselectAllAsync)
- ClearSelection
Pass a row’s visible index to the DeselectRow
method to remove that row from selection. Call the SelectRow method to select a row with the specified visible index.
Note
Rows that are filtered out and child rows of collapsed items do not have visible indexes. You cannot change the selection state of such rows with Deselect
and Select
When the TreeDeselect
method to ensure that the specified data row is loaded.
To access data items that correspond to selected rows, do one of the following:
- In multiple selection mode, implement two-way binding for the SelectedDataItems property or handle the SelectedDataItemsChanged event.
- In single selection mode, implement two-way binding for the SelectedDataItem property or handle the SelectedDataItemChanged event.
Tip
When you call the SelectDeselect
method, the component sends a callback and redraws the Tree
The following example selects and deselects the first row:
@inject EmployeeTaskService EmployeeTaskService
<style>
.my-button {
width: 200px;
}
</style>
<DxTreeList @ref="MyTreeList"
Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
AllowSelectRowByClick="true"
@bind-SelectedDataItems="@SelectedDataItems">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
<DxButton Click="() => MyTreeList.SelectRow(0)" CssClass="my-button" Text="Select First Row" />
<DxButton Click="() => MyTreeList.DeselectRow(0)" CssClass="my-button" Text="Deselect First Row" />
@code {
List<EmployeeTask> TreeListData { get; set; }
IReadOnlyList<object> SelectedDataItems { get; set; }
ITreeList MyTreeList { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
}
For more information about selection in the TreeList component, refer to the following topic: Selection and Focus in Blazor TreeList.