Help us shape the 2021 DevExtreme Roadmap. Take our 5 minute survey.

Focused Row

The focused row feature allows you to display master-detail relationships and improve navigation through records.

View Demo

To allow users to focus rows, set the focusedRowEnabled property to true.

Users can control the focused row using the following mouse and keyboard commands:

Mouse ClickFocuses a row.
↑ / ↓ Focuses the next/previous row.
← / → Focuses the cell to the left/right.
Esc Removes highlighting from the focused cell.

You can specify the initially focused row using the focusedRowKey or focusedRowIndex property. The grid is scrolled down to it. If you also set the focusedColumnIndex property, a specific cell in this row is focused.

$(function() {
        // ...
        focusedRowEnabled: true,
        focusedRowIndex: 0, // focus the first row
        // or
        // focusedRowKey: 100,
        focusedColumnIndex: 0 // focus the first cell
<dx-data-grid ...
    [focusedRowIndex]="0" <!-- focus the first row -->
    [focusedColumnIndex]="0"> <!-- focus the first cell -->
import { DxDataGridModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
    imports: [
        // ...
    // ...

Change the same properties using the option(optionName, optionValue) method to focus a row or cell programmatically. You can also use the navigateToRow(key) method to focus a row. This approach is more typical of jQuery and ASP.NET MVC Controls. With JavaScript frameworks, use property binding.

var dataGrid = $("#dataGridContainer").dxDataGrid("instance");
dataGrid.option("focusedRowKey", 100);
// or

The DataGrid raises events before and after a row or cell is focused. Use the onFocusedRowChanging/onFocusedRowChanged and onFocusedCellChanging/onFocusedCellChanged functions to handle these events. You can perform custom actions in these functions, for instance, customize keyboard navigation, as shown in the onFocusedCellChanging example.