Error with popup open and without annotation

2 posts, 0 answers
  1. Xavier
    Xavier avatar
    28 posts
    Member since:
    Dec 2010

    Posted 02 Mar Link to this post

    Hi,

    It’s posible not close grid popup if I have added in modelstate an error on créate or update method of controller.

    public ActionResult DirectInCreate([DataSourceRequest]DataSourceRequest request, DirectInViewModel service)
            {
                if (ModelState.IsValid)
                {
                    if (service.OrigenID == 0)
                    {
                        string errorMessage = string.Format("El camp Productor es obligatori.");
                        ModelState.AddModelError("", errorMessage);
                    }
                    Else

    function onError(e, gridName) {
            if (e.errors) {
                var message = "Errors:\n";
                $.each(e.errors, function (key, value) {
                    if ('errors' in value) {
                        $.each(value.errors, function () {
                            message += this + "\n";
                        });
                    }
                });
                var grid = $("#" + gridName).data("kendoGrid");
                grid.one("dataBinding", function (e) {
                    e.preventDefault();
                })
                alert(message);
                grid.cancelChanges();
            }
        }

     

     

    Thanks in advance.

     

     

    Xavier de la Rubia.

  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 04 Mar Link to this post

    Hello Xavier,

    The code snippet which you post should prevent the popup for closing. You can check out the following code library which shows the same functionality: http://www.telerik.com/support/code-library/handling-server-side-validation-errors-during-pop-up-editing
    Also I am sending you a simple example based on this code library which shows the desired functionality.

    I hope this helps.

    Regards,
    Radoslav
    Telerik
    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. UI for ASP.NET MVC is VS 2017 Ready
Back to Top