DxTreeList.IsRowSelected(Int32) Method
Returns whether the specified row is selected.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool IsRowSelected(
int visibleIndex
)
Parameters
Name | Type | Description |
---|---|---|
visibleIndex | Int32 | The row’s visible index. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Call the IsRowSelected
method to identify whether the specified TreeList row is selected. The IsDataItemSelected method allows you to check whether the row that corresponds to the specified data item is selected.
Note
When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the IsRowSelected
method to ensure that the specified data row is loaded.
@inject EmployeeTaskService EmployeeTaskService
<style>
.my-button {
width: 200px;
}
</style>
<DxTreeList @ref="MyTreeList"
Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
@bind-SelectedDataItems="@SelectedDataItems">
<Columns>
<DxTreeListSelectionColumn />
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
<DxButton Text="Is First Row Selected" CssClass="my-button"
Click="() => IsRowSelectedInfo = MyTreeList.IsRowSelected(0)" />
<DxButton Text="Is First Data Item Selected" CssClass="my-button"
Click="() => IsDataItemSelectedInfo = MyTreeList.IsDataItemSelected(TreeListData.First())" />
<div><b>Is First Row Selected</b>: @IsRowSelectedInfo</div>
<div><b>Is First Data Item Selected</b>: @IsDataItemSelectedInfo</div>
@code {
List<EmployeeTask> TreeListData { get; set; }
IReadOnlyList<object> SelectedDataItems { get; set; }
ITreeList MyTreeList { get; set; }
bool IsRowSelectedInfo { get; set; }
bool IsDataItemSelectedInfo { 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.