DxGrid.FocusedRowEnabled Property
Specifies whether the row focus is enabled.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[DefaultValue(false)]
[Parameter]
public bool FocusedRowEnabled { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Boolean | false |
|
Remarks
Set the FocusedRowEnabled
property to true
to allow the Grid to focus data and group rows. Only one row can be focused at a time within the current page. When a page changes, the row loses focus.
<DxGrid @ref="Grid" FocusedRowEnabled="true" Data="@Products" PageSize="6" >
<Columns>
<DxGridDataColumn FieldName="ProductId" />
<DxGridDataColumn FieldName="ProductName" />
<DxGridDataColumn FieldName="UnitPrice" />
<DxGridDataColumn FieldName="UnitsInStock" />
<DxGridDataColumn FieldName="QuantityPerUnit" />
</Columns>
</DxGrid>
Focus can be moved in the following ways:
- A user clicks a row.
- A data row switches to edit mode.
- You call the SetFocusedDataItemAsync(Object) or SetFocusedRowIndex(Int32) method.
- The Grid moves focus on the initial load or when visible rows change (for instance, when you apply a filter or sorting, or a page changes).
When the focused row changes, the component raises the FocusedRowChanged event.
Methods Designed to Work With the Focused Row
- Data row
GetFocusedRowIndex() - Returns the visible index of the focused row or
-1
if the Grid has no data to display.SetFocusedRowIndex(Int32) - Moves focus to the row with the specified visible index.
IsRowFocused(Int32) - Identifies whether the row with the specified visible index is focused.
GetFocusedDataItem() - Returns the data item bound to the focused data row.
SetFocusedDataItemAsync(Object) - Moves focus to the row bound to the specified data item.
IsDataItemFocused(Object) - Returns whether the row bound to the specified data item is focused.
- Group row
A group row has no bound data item, so you can work with a visible index only.
GetFocusedRowIndex() - Returns the visible index of the focused row or
-1
if the Grid has no data to display.SetFocusedRowIndex(Int32) - Moves focus to the row with the specified visible index.
IsRowFocused(Int32) - Identifies whether the row with the specified visible index is focused.
- New row
The Grid focuses a new row once it appears. The new row has no bound data item and the row’s visible index equals
-1
.IsEditingNewRow() - Identifies whether a new row is being edited.
StartEditNewRowAsync(String) - Shows, focuses, and starts editing a new row.
For more information about row focus in the Grid component, refer to the following topic: Selection and Focus in Blazor Grid.