# Navigating Through Hierarchical Grid Rows with Tab Key

## Environment

<table>
<tbody>
<tr>
<td>Product</td>
<td>Telerik UI for ASP.NET MVC Grid</td>
</tr>
<tr>
<td>Version</td>
<td>2024.3.1015</td>
</tr>
</tbody>
</table>

## Description

How can I enable `Tab` key navigation through the expanding arrows of the parent rows in a hierarchical Grid?

The [`Navigatable()`](https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/gridbuilder#navigatablesystemboolean) option enables the keyboard navigation functionality of the Grid. When you focus on a cell that holds the expanding arrow of the parent row, you can use the `Arrow` keys to navigate through the expanding arrow cells vertically. In this article, you will learn how to implement a custom JavaScript logic to allow `Tab` key navigation through the cells with the expanding arrows.

## Solution

1. Enable the keyboard navigation functionality of the Grid by setting the `Navigatable()` in your Grid configuration.
2. Handle the [`click`](https://api.jquery.com/click/) event on the Grid's table cells with class `k-hierarchy-cell` and set the clicked cell as a current focused cell in the Grid.
3. Handle the [`keydown`](https://api.jquery.com/keydown/) event on the Grid's table. When the `Tab` key is pressed, prevent the default event action and manually set the focus to the expanding arrow cell of the next row.

```Razor HtmlHelper
    @(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
        .Name("grid")
        .ClientDetailTemplateId("clientDetailTemplate")
        .Navigatable()
        ...// Additional configuratiion.
    )
```

```JS scripts
    <script>
        $(document).ready(function () {
            var grid = $('#grid').data('kendoGrid');

            grid.table.on("click", ".k-hierarchy-cell", function () {
                grid.current($(this)); // Focus the expanding arrow cell when clicked.
            });

            grid.table.on('keydown', function (e) {
                if (e.keyCode === 9) { // Check if Tab key is pressed.
                    e.preventDefault();
                    var currentCell = grid.current(); // Get the current table cell.
                    var nextRow = $(currentCell).closest("tr").next(); // Get the next row element.
                    var cellOnNextRow = $(nextRow).find(`td:first`); // Get the first cell on the next row.
                    grid.current(cellOnNextRow); // Focus the cell with the expanding arrow.
                }
            });
        });
    </script>
```

For a runnable example based on the code above, refer to the [REPL example on vertically tabbing through the hierarchy cells of the Grid](https://netcorerepl.telerik.com/QovabVvL04DSpzlV45).

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)

* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)

* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)

* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)

* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
