Server Validation of Grid

3 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 18 Oct 2015 Link to this post

    I am having a play around with the grid.  I have implemented the following example where batch update/create/delete from this post kendo-grid-batch-incell-save-changes-with-single-trigger-for-create-update-destroy.  This works nicely where I get the rows being created/updated/deleted.

    However, if I need to do some custom server side validation in a save event before the changes are committed - if there are any errors, is it possible to return the errors and set them back in the grid supposing my save send handler is:

    function sendSaveAllData() {
                var grid = $('#mygrid').data("kendoGrid");
                var finalData = ...;
                // send the data with one request to the server
                    url: "@Url.Action("SaveAllBatchChanges", "MyController")",
                    data: finalData,
                    type: "POST",
                    error: function () {
                        //Handle the server errors
                    success: function (data) {
                        //alert("update on server is completed");
                        showMessage('success', 'My Batch', 'Successfully saved batch changes.')
                        //refresh the grid
                        grid.dataSource._destroyed = [];

    With controller method:

    public ActionResult SaveAllBatchChanges(
                [Bind(Prefix = "updated")]List<BatchEditModel> updated,
                [Bind(Prefix = "new")]List<BatchEditModel> created,
                [Bind(Prefix = "deleted")]List<BatchEditModel> destroyed)
                // do some validation before notifying server
                // save if valid
                return Json("Success!");

    At the minute I show a popup message to the user which reads success - but I haven't got any code in place currently to do the validate until I find something concrete to put in place.

    Ideally I want to set cell style of errors in the grid if possible back in the browser - ie red background colour if the cell contains an error. 

    Is there a way to manually set error messages in the grid (client side) and highlight the error cells from an external ajax post?




  2. Vladimir Iliev
    Vladimir Iliev avatar
    2194 posts

    Posted 21 Oct 2015 Link to this post

    Hi Andez,

    Please note that the linked solution is a custom one and therefor the developer is entirely responsible for further customizing and supporting it. Currently I could only suggest to check the "GridInCellEditWithServerValidation" demo available in the following forum post for example of how to find given row and apply red borders to notify the user about the server error. 

    Vladimir Iliev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 21 Oct 2015 in reply to Vladimir Iliev Link to this post

    Looks good thanks.  Will check it out
Back to Top