Return Error Message to Grid

4 posts, 1 answers
  1. Oliver
    Oliver avatar
    19 posts
    Member since:
    Sep 2013

    Posted 09 Oct 2014 Link to this post

    How can I return a Custom error for a Grid Operation.

    E.g.: If the database delete is not possible show a popup that something is gone wrong.

    Controller Method:
    public ActionResult DestroyEmploymentStatus([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]List<EmploymentStatusViewModel> employmentStatuses)
        if (employmentStatuses.Any())
            foreach (var esvm in employmentStatuses)
                var es = db.EmploymentStatuses.Find(esvm.Id);
        return Json(employmentStatuses.ToDataSourceResult(request, ModelState));

  2. Answer
    Rosen avatar
    3249 posts

    Posted 13 Oct 2014 Link to this post

    Hi Oliver,

    You can add the error to the ModelState errors collection. The ToDataSource extension method will serialize the errors in the response and on the server you will be able to get the error in the DataSource error event. More detailed information can be found in this helps article.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Debi
    Debi avatar
    1 posts
    Member since:
    Mar 2016

    Posted 05 Oct 2017 in reply to Rosen Link to this post

    But-- what if I ALSO need to return the total row count for server side paging?
  4. Stefan
    Stefan avatar
    1581 posts

    Posted 09 Oct 2017 Link to this post

    Hello, Debi,

    The ToDataSourceResult method should automatically return the total number of items in the response. This can be observed in our demo, by paging the Grid and checking the response in the network tab:

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top