New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Creating a Dynamic Grid with Popup Editing
Updated on Oct 28, 2025
Environment
| Product | Grid for Progress® Telerik® UI for ASP.NET Core |
Description
How can I create a dynamic Telerik UI Grid in ASP.NET Core that uses a custom popup editor template?
Solution
The suggested approach demonstrates how to bind a DataTable to a Telerik UI Grid and enable the Popup editing.
- Populate the Grid columns based on the available
Model.Columns.Model.Columnsis the collection of columns of the createdDataTable. - Set the column title by using the
Captionproperty of theDataColumn. - Activate the Popup editing and specify the name of the custom Popup template:
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("DynamicPopupEditor")). - Define the
Modelin theDataSourceconfiguration by using theColumnNameandDataTypeproperties of theDataColumns. Also, it is important to set the ModelIdto match theDataTablePrimaryKey. - Store the
DataTableColumnsinViewData["modelData"]to initialize the editors in the Popup form. For more information, refer to theControllerin the GitHub project. - Create a View for the editor template in the
~/Views/Shared/EditorTemplatesfolder. Ensure that the name of the View matches theTemplateNamespecified in the.Editable()option. - Define an editor for each data type in the editor template and bind the editor to the
Modelproperty by using thedata-bindattribute, that is,.HtmlAttributes(new { data_bind= $"value: {dcolumn.ColumnName}" }).
Razor
@model System.Data.DataTable
@(Html.Kendo().Grid<dynamic>()
.Name("Grid")
.Columns(columns =>
{
foreach (System.Data.DataColumn dcolumn in Model.Columns) //Loop through the DataColumns.
{
switch (dcolumn.DataType.ToString())
{
case "System.DateTime":
columns.Bound(dcolumn.ColumnName).Title(dcolumn.Caption).Format("{0:d}"); //If the column DataType is "DateTime", format the date by using the Format() method.
break;
default:
columns.Bound(dcolumn.ColumnName).Title(dcolumn.Caption);
break;
}
}
columns.Command(com => com.Edit());
})
.Pageable()
.Sortable()
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("DynamicPopupEditor")) //Specify the name of the custom Popup template ("~/Views/Shared/EditorTemplates/DynamicPopupEditor.cshtml").
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
var id = Model.PrimaryKey[0].ColumnName;
model.Id(id); //Set the Model Id
foreach (System.Data.DataColumn column in Model.Columns)
{
var field = model.Field(column.ColumnName, column.DataType);
if (column.ColumnName == id) {
field.Editable(false);
}
}
})
.Read(read => read.Action("Customers_Read", "DynamicPopupEditing"))
.Update(read => read.Action("Customers_Update", "DynamicPopupEditing"))
)
)For the complete implementation of the suggested approach, refer to this GitHub project.