DxGrid.IsRowFocused(Int32) Method
Identifies whether the row with the specified visible index is focused.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v23.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
Use the IsRowFocused
method to determine whether the row with the specified visible index is focused. You can use the IsDataItemFocused(Object) method to determine whether the row bound to the specified data item is focused.
The code sample below calls the IsRowFocused
method in the CustomizeElement event handler to specify a custom background color for the focused row.
<DxGrid Data="@Data" PageSize="6"
FocusedRowEnabled="true" CustomizeElement="Grid_CustomizeElement" >
<Columns>
<DxGridDataColumn FieldName="ContactName" />
<DxGridDataColumn FieldName="CompanyName" />
<DxGridDataColumn FieldName="City" />
<DxGridDataColumn FieldName="Country" />
</Columns>
</DxGrid>
@code {
object Data { get; set; }
void Grid_CustomizeElement(GridCustomizeElementEventArgs e) {
if (e.ElementType == GridElementType.DataCell || e.ElementType == GridElementType.GroupCell) {
if (e.Grid.IsRowFocused(e.VisibleIndex)) {
e.Style = "background-color: red";
}
}
}
//...
}
For more information about row focus in the Grid component, refer to the following topic: Selection and Focus in Blazor Grid.