Refreshing Grid After Update/Create and Displaying Skipped Records in Popup
Environment
| Product | Kendo UI for ASP.NET Core Grid |
| Version | 2026.1.212 |
Description
I want to refresh the Kendo UI for ASP.NET Core Grid after creating or updating records and display skipped records in a popup. Skipped records represent duplicates or entries that were not processed during the create operation.
This knowledge base article also answers the following questions:
- How to refresh the grid after adding or editing data?
- How to handle skipped records in Kendo UI for ASP.NET Core Grid?
- How to show a popup for skipped records after a grid update?
Solution
Refreshing the Grid After Update/Create
To refresh the grid after a data operation, bind the change event of the grid's DataSource and invoke the read method. Update the DataSource configuration to include the change event as shown below:
.DataSource(ds => ds.Ajax()
.Read(r => r.Url(Url.Page("OnCallAdmin", "Read")).Data("forgeryTokenRead"))
.Update(u => u.Url(Url.Page("OnCallAdmin", "Update")).Data("forgeryToken"))
.Destroy(r => r.Url(Url.Page("OnCallAdmin", "Delete")).Data("forgeryToken"))
.Create(r => r.Url(Url.Page("OnCallAdmin", "Create")).Data("forgeryTokenCreate"))
.Model(m => m.Id(id => id.ClinicianId))
.Events(e => e.Change("change"))
)
Define the change JavaScript function:
function change(e) {
if (e.action === "sync") {
var grid = $("#ScheduleDetailsGrid").data("kendoGrid");
grid.dataSource.read();
grid.refresh();
}
}
Adding Error Handling
Add the Error event handler to the DataSource configuration for managing CRUD operation errors:
.Events(e => {
e.Change("change");
e.Error("onError");
})
Define the onError JavaScript function for handling errors:
function onError(e) {
var message = "An error occurred.";
if (e.errors) {
message = "";
$.each(e.errors, function(key, value) {
if ('errors' in value) {
$.each(value.errors, function() {
message += this + "\n";
});
}
});
}
alert(message); // Replace alert with a Kendo Notification or Window for better UX.
}
Displaying Skipped Records in a Popup
Modify the server-side Create action to include skipped records in the JSON response:
var scheduleList = GetSchedules(details.SiteId, details.DepartmentId, details.StartDate, details.EndDate).ToList();
return new JsonResult(new {
Data = scheduleList.ToDataSourceResult(request, ModelState),
SkippedRecords = duplicates
});
Update the change event handler to display a popup with skipped records after a sync operation:
function change(e) {
if (e.action === "sync") {
var grid = $("#ScheduleDetailsGrid").data("kendoGrid");
grid.dataSource.read();
grid.refresh();
// Check for skipped records in the response
if (e.response && e.response.SkippedRecords && e.response.SkippedRecords.length > 0) {
showSkippedRecordsPopup(e.response.SkippedRecords);
}
}
}
function showSkippedRecordsPopup(skippedRecords) {
var message = "The following records were skipped:<br/>";
skippedRecords.forEach(function(record) {
message += "Date: " + kendo.toString(record.Date, "MM/dd/yyyy") +
", Clinician: " + record.LastName + ", " + record.FirstName +
", DayType: " + record.DayType + "<br/>";
});
$("<div />").kendoWindow({
title: "Skipped Records",
content: message,
width: "400px",
height: "200px",
modal: true
}).data("kendoWindow").center().open();
}
Summary
- Use the
changeevent to refresh the grid after update or create operations. - Add error handling using the
Errorevent. - Display skipped records in a popup by returning them in the server response and processing them in the
changeevent.