# Edit Three-Level Hierarchical Grids

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid</td>
 </tr>
 <tr>
  <td>Product version</td>
  <td>2025.1.227</td>
 </tr>
</table>

## Description

How can I implement a three-level hierarchical editable Grid?

## Solution

You can achieve this requirement using the following implementation:

1. Define the main InLine editable Grid:

   ```Razor HtmlHelper
   @(Html.Kendo().Grid<GridEditing3LevelHierarchyEmployee>()
       .Name("Employees")
       .ClientDetailTemplateId("OrderDetailsTemplate")
       ... // Additional configuration.
   )
   ```

2. Define the first detail Grid with enabled InLine editing mode:

   ```Razor HtmlHelper
   <script type="text/kendo" id="OrdersTemplate">
   @(Html.Kendo().Grid<GridEditing3LevelHierarchyOrder>()
       .Name("Orders_#=EmployeeID#")
       .Columns(columns =>
       {
           ... // Columns configuration.
       })
       .Editable(editable => editable.Mode(GridEditMode.InLine))
       .ToolBar(tools => tools.Create())
       .Pageable()
       .Sortable()
       .Filterable()
       .DataSource(source => source
           .Ajax()
           .Model(model =>
           {
               model.Id(o => o.OrderID);
               model.Field(o => o.OrderID).Editable(false);
           })
           .Read(read => read.Action("Read_Orders", "Orders", new { id = "#=EmployeeID#" }))
           .Update(update => update.Action("Update_Order", "Orders"))
           .Create(create => create.Action("Create_Order", "Orders", new { id = "#=EmployeeID#" }))
           .Destroy(destroy => destroy.Action("Destroy_Order", "Orders"))
       )
       .ClientDetailTemplateId("OrderDetailsTemplate")
       .ToClientTemplate()
   )
   </script>
   ```

3. Define the second detail Grid with enabled InLine editing mode. Its parent Grid is **Orders\_#=EmployeeID#**:

   ```Razor HtmlHelper
   <script type="text/kendo" id="OrderDetailsTemplate">
   @(Html.Kendo().Grid<GridEditing3LevelHierarchyOrder_Detail>()
       .Name("OrderDetails_#=OrderID#")
       .Columns(columns =>
       {
           ... // Columns configuration.
       })
       .Editable(editable => editable.Mode(GridEditMode.InLine))
       .ToolBar(tools => tools.Create())
       .Pageable()
       .Sortable()
       .Filterable()
       .DataSource(source=> source
           .Ajax()
           .Model(model =>
           {
               model.Id(o => o.OrderID);
               model.Field(o => o.ProductID).DefaultValue(1);
           })
           .Read(read => read.Action("Read_OrderDetails", "OrderDetails", new { id = "#=OrderID#" }))
           .Update(update => update.Action("Update_Order_Detail", "OrderDetails"))
           .Create(create => create.Action("Create_Order_Detail", "OrderDetails", new { id = "#=OrderID#" }))
           .Destroy(destroy => destroy.Action("Destroy_Order_Detail", "OrderDetails"))
       )
       .ToClientTemplate()
   )
   </script>
   ```

To review the complete example, refer to the [project on how to implement editable Grids of a three-level hierarchy](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridEditing3LevelHierarchy) in ASP.NET MVC applications.

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

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)
* [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 Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
