Back to Devexpress

DxGrid.IsRowFocused(Int32) Method

blazor-devexpress-dot-blazor-dot-dxgrid-dot-isrowfocused-x28-system-dot-int32-x29.md

latest3.0 KB
Original Source

DxGrid.IsRowFocused(Int32) Method

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

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
public bool IsRowFocused(
    int visibleIndex
)

Parameters

NameTypeDescription
visibleIndexInt32

The row’s visible index.

|

Returns

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

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

Implements

IsRowFocused(Int32)

See Also

DxGrid Class

DxGrid Members

DevExpress.Blazor Namespace