New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Access Current Model in the Grid Popup
Environment
Product | Telerik UI for ASP.NET MVC Grid |
Product Version | 2025.1.227 |
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:
-
Enable the Popup editing of the Grid and define its custom editor template:
Razor.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("CustomPopUpEditor").AdditionalViewData(new {GridName = GridName}))
-
Access the additional data in the custom Popup editor template:
Razor@{ 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 in the UI for ASP.NET MVC Examples repository.
More ASP.NET MVC Grid Resources
- ASP.NET MVC Grid Documentation
- ASP.NET MVC Grid Demos
- ASP.NET MVC Grid Product Page
- Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)
- Telerik UI for ASP.NET MVC Forums