This is a migrated thread and some comments may be shown as answers.

Error with popup open and without annotation

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 02 Mar 2016, 03:44 PM

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.

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 04 Mar 2016, 01:26 PM
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
Tags
Grid
Asked by
Xavier
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or