Skip to main content
All docs
V25.1
  • DxGrid.IsRowFocused(Int32) Method

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

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.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

    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.

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

    Implements

    See Also