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

how to show dialog box after returning from controller's action method.


I recently started using syncfusion grid and not able to figure out how to show a dialog box after any insert ,delete or update event. I am using InertURL ,UpdateURL and RemoveURL function to save data to my database. i am looking for something like Ajax onSuccess() method which gets triggered after a ajax call. how do i achieve this  using syncfusion InsertUrl() and other methods.
this is how my grid looks like.

        .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).InsertURL(Url.Action("DialogInsert", "DesignationMaster", null, Request.Url.Scheme)).UpdateURL(Url.Action("UpdateQuestion", "DesignationChange", null, Request.Url.Scheme)).RemoveURL("DeleteQuestion").Adaptor(AdaptorType.RemoteSaveAdaptor))
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().ShowConfirmDialog(true).EditMode(EditMode.DialogTemplate).DialogEditorTemplateID("#template"); })
        .ContextMenuSettings(contextMenu =>

         .PageSettings(page =>
         .FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
         .ClientSideEvents(eve =>

         .ToolbarSettings(toolbar =>
             toolbar.ShowToolbar().ToolbarItems(items =>
         .Columns(col =>

             col.Field(p => p.designationCode).HeaderText("Designation Code").IsPrimaryKey(true).TextAlign(TextAlign.Left).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(70).Add();
             col.Field(p => p.description).HeaderText("Description").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add();
             col.Field(p => p.salaryDesc).HeaderText("Salary Type").EditType(EditingType.Dropdown).Width(65).Add();
             col.Field(p => p.salaryCode).HeaderText("Salary Type").EditType(EditingType.Dropdown).Width(65).Visible(false).Add();

             col.Field(p => p.normalWokringHrs).HeaderText("Salary Type").Width(65).Visible(false).Add();
             col.Field(p => p.ramadanWorkingHrs).HeaderText("Salary Type").Width(65).Visible(false).Add();
             col.Field(p => p.dailyRate).HeaderText("Salary Type").Width(65).Visible(false).Add();
             col.Field(p => p.hourlyRate).HeaderText("Salary Type").Width(65).Visible(false).Add();

             col.Field(p => p.otAllowed).HeaderText("O.T.").Width(40).EditType(EditingType.Boolean).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add();
             col.Field(p => p.jobCategoryCode).HeaderText("JCC").EditType(EditingType.Dropdown).Width(55).Add();

             col.Field(p => p.jobCategoryDesc).HeaderText("JCD").Width(85).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add();


and this is my dialog box

 <div class="control">

            @<div class="cnt">
                Do you really leave the session?
        .Title("Error List")
        .Animation(animate => animate.Show(show => show.Duration(500).Effect("slide")).Hide(hide => hide.Duration(500).Effect("fade")))


my controller returns a Serialized list of errors if some error occurs while performing server side operation. please tell me where should i write $("#ErrorList").ejDialog("open") function in script to show these errors.


1 Reply

MS Mani Sankar Durai Syncfusion Team November 11, 2016 08:34 AM UTC

Hi Fit, 
Thanks for contacting Syncfusion support. 
We have analyzed your query and we can achieve it by using actionComplete and actionFailure event in grid.  
It is possible to intercept the response to Update, Remove and Insert operations in actionComplete event of grid which is similar to success action of grid.  
ActionComplete event will be triggered after the CRUD operation is successful whereas the ActionFailure event will be triggered after the failure/exception in CRUD operation. 
So, if you would like to perform any action based on success/failure, you can mention them in ActionComplete and ActionFailure separately. From there you can able to open the dialog. 
Please refer the below code example. 
           .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/OrderTables/Update") 
                            .ClientSideEvents(eve => { eve.ActionFailure("Failure").ActionComplete("complete"); }) 
<script type="text/javascript"> 
    function complete(args) { 
        if(args.requestType == "save") 
    function Failure(args) { 
        if (args.requestType == "save") 
        var str = ""; 
        str = args.error.statusText; 
From the above code example we have applied the model state validation for the columns in grid. 
So that when it gets failed and returns error we can tends to trigger actionFailure event. 
For your convenience we have prepared a sample that can be downloaded from the below link. 
Also please refer the documentation link about actionComplete and actionFailure event. 
Please let us know if you need further assistance. 
Manisankar Durai. 

Live Chat Icon For mobile
Up arrow icon