# Access Current Model in the Grid Popup

## 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 access the currently editable data item in the Popup editor template of the Telerik UI for ASP.NET MVC Grid?

## Solution

You can implement this requirement as follows:

1. Enable the Popup editing of the Grid and define its custom editor template:

   ```Razor HtmlHelper
   .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("CustomPopUpEditor").AdditionalViewData(new {GridName = GridName}))
   ```

2. Access the additional data in the custom Popup editor template:

   ```Razor HtmlHelper
   @{
       string ChildGridName = "PopupGrid";
   }

   <script>
       function getCurrentParentId() {
           var uid = $("#@ChildGridName").closest("[data-uid]").data("uid");
           var parentGrid = $("#@ViewData["GridName"]").data("kendoGrid");
           var model = parentGrid.dataSource.getByUid(uid);
           return { parrentGridRecordId: model.OrderID };
       }
   </script>

   @(Html.Kendo().Grid<Telerik.Examples.Mvc.Areas.GridEditingPopUpAccessModel.Models.Order>()
       .Name(ChildGridName)
       .Columns(columns => {
           columns.Bound(p => p.OrderID);
           columns.Bound(p => p.OrderDescription);
           columns.Bound(p => p.OrderDate);
       })
       .Pageable()
       .Scrollable()
       .DataSource(dataSource => dataSource
           .Ajax()
           .ServerOperation(false)
           .Model(model => {
               model.Id(p => p.OrderID);
           })
           .Read(read => read.Action("ForeignKeyColumn_Read", "Home").Data("getCurrentParentId"))
       )
   )
   ```

To see the complete example, refer to the [ASP.NET MVC application](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/GridEditingPopUpAccessModel) in the [UI for ASP.NET MVC Examples repository](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master).

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