We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

MVC grid EditMode.Dialog insert action freezes after server error

Hello

we are using the latest version of MVC Components. We have a page with the following code

@(Html.EJ().Grid<LessonGroupOutput>("GroupLessonsGrid")
    .Locale("el-GR")
    .Datasource(ds => ds.Json((IEnumerable<object>)Model)
        .InsertURL("LessonGroups/Create")
        .UpdateURL("LessonGroups/Update")
        .RemoveURL("LessonGroups/Delete")
        .Adaptor(AdaptorType.RemoteSaveAdaptor))
    .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Dialog); })
    .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
                {
                    items.AddTool(ToolBarItems.Add);
                    items.AddTool(ToolBarItems.Edit);
                    items.AddTool(ToolBarItems.Delete);
                }))
    .AllowPaging()
    .PageSettings(page => page.PageSize(20))
    .AllowSorting()
    .Columns(col =>
    {
        col.Field("Id").HeaderText("Κωδικός").IsPrimaryKey(true).TextAlign(TextAlign.Left)
            .ValidationRules(v => v.AddRule("required", true).AddRule("number", true))
            .Width(20).Add();
        col.Field("Name").HeaderText("Όνομα").Width(180).Add();
    })
            .ClientSideEvents(events => { events.ActionFailure("OnActionFailure"); })
)
 
<script>
    function OnActionFailure(args) {
        alert(args.error.status + ':' + args.error.statusText, 'error');
    }
</script>


When we create a new object, the dialog form appears, we set the data and send them through the ajax call to the server.When the server responds with an error (throws dbexception for example) the triggered alert shows the error but when we close the alert dialog the page still shows the insert dialog form with the circular waiting popup. Is there a way to cancel the insert dialog form and get back to the grid?


Thanks

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team April 20, 2016 09:44 AM UTC

Hi Dimitris,

Thanks for contacting Syncfusion support.

If any server side error is thrown then grid waiting popup will load and to hide the waiting popup and get back to the grid we can use the actionFailure event. This event triggered for every grid action server failure event. Refer to the sample, code sample and Help document,

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/7z/RemoteSaveAdaptorSample137393794


Code example:

<Grid>


@(Html.EJ().Grid<object>("FlatGrid")

                   .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Grid/Update")

                   .InsertURL("/Grid/Inser").RemoveURL("/Grid/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))

                   .AllowPaging()

                       .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Dialog); })

                  

                    })


                  . . . . .


                    .ClientSideEvents(eve=>eve.ActionFailure("actionFailure"))

                

                 . . . . .

               

)


<actionFailure event>


function actionFailure(args) {


        alert(args.error.error().statusText);


        $("#" + this._id + "_dialogEdit").ejDialog("close"); // Close the dialog edit form



        this.element.ejWaitingPopup("hide");//disable the Waiting popup

    }


Help document: http://help.syncfusion.com/js/api/ejgrid#events:actionfailure

If we misunderstood your query, then provide more details about that.

Regards,
Venkatesh Ayothiraman.

Loader.
Live Chat Icon For mobile
Up arrow icon