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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to suppress grid confirmation messages

Problem:

1. Showing confirmation dialog while saving the changes of the current page.

2. Disable the confirmation dialog while navigating to another page and save the changes.

 

Solution: Showing confirmation dialog while saving the changes of the current page.

We can achieve the above requirement by using ShowConfirmDialog property of the grid while using Batch editing feature.

While using batch editing feature of the grid, the ShowConfirmDialog property of the EditSettings is enabled by default and so whenever the changes of the current page get saved it will show the confirmation dialog.

And also while navigating to another page without saving the changes of the current page it will show the confirmation dialog for confirming to save the changes.

Example:

We can enable the Batch editing feature and ShowConfirmDialog property of the grid as follows.

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

.Datasource((IEnumerable<object>)ViewBag.datasource)

.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch).ShowConfirmDialog(true); })

.AllowPaging()

 .Columns(col =>

        {

            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();

            col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();

            col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add();

            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}") .Add();

            col.Field("ShipCity").HeaderText("Ship City").Width(110).Add();

            col.Field("ShipName").HeaderText("Ship Name").Width(110).Add();

        }))

)

Result:

(i) While saving edited record details in same page by clicking on the save button in toolbar.

 

(ii) While saving the edited records details when navigating from one page to another.

Solution: Disable the confirmation dialog while navigating to another page and saving the changes.

 

We can prevent the confirmation dialog by set “showConfirmDialog” property of the editSettings as “false” in ActionBegin event of the grid while navigating to another page.

 

Example:

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

         .Datasource((IEnumerable<object>)ViewBag.datasource)

         

         .ClientSideEvents(eve=>{eve.ActionBegin("begin").ActionComplete("complete");})

 )

<script type="text/javascript">

function begin(args) {

var obj = $("#Grid").data("ejGrid");

if (args.requestType == "paging") {

//Getting edited records details using getBatchChanges method while navigating to another page

temp = obj.getBatchChanges();

$("#Grid").ejGrid("option", {

//set showConfirmDialog property as false

"editSettings": { showConfirmDialog: false }

});

}

}

 

 

In the above code snippet we have usedgetBatchChanges method for getting the changes of the current page and saved the changes in the global variable

We have assigned the changes of previous page to the “batchChanges” property of the grid for saving the changes in ActionComplete event of the grid while navigating to another page.

function complete(args)

{

if (args.requestType == "paging") {

var obj = $("#Grid").data("ejGrid");

//Enable showConfirmationDialog property

$("#Grid").ejGrid("option", { "editSettings": { showConfirmDialog: true } });

//Assigning edited records details(temp) to batchChanges property.

obj.batchChanges = temp;

//Saving edited records using batchSave method

$("#Grid").ejGrid("batchSave");

}}

</script>

 

 

In the above code snippet we have set the showConfirmDialog property of the editSettings as “trueagain for showing the confirmation dialog in the current page while clicking the save button from the toolbar.

Result:

Figure 1: Editing a record

The edited records are saved automatically while navigating from one page to another, without display any confirmation dialog.

Figure 2: Saving an edited record without displaying confirmation message.

 

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3016 12/10/2014 08/03/2015 ASP.NET MVC Grid 4
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon