Please see my other Telerik articles.
Providing feedback to users upon submitting a grid
In this article I will demonstrate how to use Telerik’s Notification control to display a Success or Failure message to the user after a submit operation, providing them feedback whether or not it worked.
I’ll start with a common grid with CRUD functionality.
.Events(e => e.RequestEnd(“onRequestEnd”))
The contents of onRequestEnd() are defined later.
Within my controller’s CRUD logic, if an error is caused preventing success, I’ll add the error to the errors collection in the model, which I’ll pass when returning to the grid.
ModelState.AddModelError(“Delete() error”, “Delete() error”);
return Json(bills.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
Within the file, I define a function I’ll use within my if…else logic to configure the current notification.
Then, I’ve added to onRequestEnd() a series of if…else statements to configure the notification based on whether or not the current grid action is create, edit (update), or delete (destroy), and whether the operation was a success or not.
Notice the check for e.reponse.Errors corresponds to any errors I added to the model in my controller (above).
My onShow() function ensures the notification displays near the top-center of the page.
Depending on which action the user performs, if it’s a success, the user is presented with a nice success message.
Or, they’re shown an error screen.