Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxGrid.IsRowFocused(Int32) Method

Identifies whether the row with the specified visible index is focused.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public bool IsRowFocused(
    int visibleIndex
)

#Parameters

Name Type Description
visibleIndex Int32

The row’s visible index.

#Returns

Type Description
Boolean

true if the row is focused; otherwise, false.

#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.

Note

The Grid bound to an Instant Feedback Data Source or GridDevExtremeDataSource loads data asynchronously in small portions (instead of the entire dataset). Before you call the IsRowFocused method, call the WaitForRemoteSourceRowLoadAsync(Int32) 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.

razor
<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";
            }
        }
    }
    //...
}

Grid Red Focused Row

For more information about row focus in the Grid component, refer to the following topic: Selection and Focus in Blazor Grid.

See Also