DxTreeList.IsRowFocused(Int32) Method
Returns whether the row with the specified visible index is focused.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool IsRowFocused(
int visibleIndex
)
Parameters
Name | Type | Description |
---|---|---|
visibleIndex | Int32 | The row’s visible index. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Call the IsRowFocused
method to determine whether the row with the specified visible index is focused. The IsDataItemFocused(Object) method allows you to determine whether the row bound to the specified data item is focused.
Note
When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the IsRowFocused
method to ensure that the specified data row is loaded.
The following code snippet calls the IsRowFocused
method in the CustomizeElement event handler to specify a custom background color for the focused row:
@inject EmployeeTaskService EmployeeTaskService
<DxTreeList Data="TreeListData"
KeyFieldName="Id"
ParentKeyFieldName="ParentId"
FocusedRowEnabled="true"
CustomizeElement="TreeList_CustomizeElement">
<Columns>
<DxTreeListDataColumn FieldName="Name" Caption="Task" />
<DxTreeListDataColumn FieldName="EmployeeName" />
<DxTreeListDataColumn FieldName="StartDate" />
<DxTreeListDataColumn FieldName="DueDate" />
</Columns>
</DxTreeList>
@code {
List<EmployeeTask> TreeListData { get; set; }
protected override void OnInitialized() {
TreeListData = EmployeeTaskService.GenerateData();
}
void TreeList_CustomizeElement(TreeListCustomizeElementEventArgs e) {
if (e.ElementType == TreeListElementType.DataCell) {
if (e.TreeList.IsRowFocused(e.VisibleIndex)) {
e.Style = "background-color: red";
}
}
}
}
For more information about row focus in the TreeList component, refer to the following topic: Selection and Focus in Blazor TreeList.