Custom confirm message

Hi,

I tried to use this code, but begin event not firing and not return custom message.

I noted that editing mode of example is normal, instead I use Dialog.

This is grid:


        @(Html.EJS().Grid<AziendeTrasportatriciVM>("GridAziendeTrasportatrici").DataSource(dataManager => { dataManager.Json(((IEnumerable<AziendeTrasportatriciVM>)Model).ToArray()).InsertUrl("InsAziendeTrasportatrici").UpdateUrl("UpdAziendeTrasportatrici").RemoveUrl("DelAziendeTrasportatrici").Adaptor("RemoteSaveAdaptor"); }).Load("load").ActionBegin("begin").ToolbarClick("toolbarClick").ActionComplete("actionComplete").ActionFailure("gridFailure").Columns(col =>

    {

        col.Field("IdAziendaTrasportatrice").IsPrimaryKey(true).Visible(false).Add();

        col.Field("RagioneSociale").AutoFit(true).Add();

        col.Field("Indirizzo").AutoFit(true).Add();

        col.Field("CAP").AutoFit(true).Add();

        col.Field("Citta").AutoFit(true).Add();

        col.Field("Email").AutoFit(true).Add();

        col.Field("Telefono").AutoFit(true).Add();


    }).AllowPaging().PageSettings(page => page.PageSizes(true)).AllowSorting().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).ShowDeleteConfirmDialog(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add","Edit","Delete", "Print", "Search" }).Render())

This is script:

function begin(args) {

            if (args.requestType == "save" || args.requestType == "delete") {

                var grid = document.getElementById("GridAziendeTrasportatrici").ej2_instances[0];

                var deleteMessage = '@BloomApp_WEB.Resources.AziendeTrasportatrici.DeleteConfirm';

                if (isupdate && args.requestType == "delete") {

                    if (confirm(deleteMessage)) {

                        //if yes ,record will delete

                    }

                    else

                        args.cancel = true // if no the record wont delete

                }

                isupdate = false

            }

        }


        function toolbarClick(args) {

            var grid = document.getElementById("GridAziendeTrasportatrici").ej2_instances[0];

            if (args.item.properties.prefixIcon == "e-delete") {

                isupdate = true

            }


        }



3 Replies

SK Sujith Kumar Rajkumar Syncfusion Team August 10, 2021 12:45 PM UTC

Hi Pio, 
 
Greetings from Syncfusion support. 
 
Based on the provided information we could see that you are trying to retrieve a custom message in the Grid’s actionBegin event and based on that perform the delete action. And your reported problem is that the actionBegin event is not triggered and custom message is not returned. We checked this problem from our end but the actionBegin event was properly triggered on performing the delete action. You can check the below sample for reference, 
 
 
But we are not clear from where you are retrieving the custom error message. So please share us the following information to validate further on this, 
 
  • Let us know from where you are retrieving the custom error message. Are you getting this message from a server request? If so, we would like to let you know that Grid actions are synchronous and hence will not wait for any async calls. So please confirm us if this is your use case based on which we will provide the further details.
  • Please confirm us if your reported problem is the actionBegin event is not triggered or if the delete action is not waiting for custom error message.
  • Syncfusion package version used.
  • Pictorial or video demonstration of the problem to understand it better.
  • If possible share us a simple sample to replicate the problem or try reproducing it in the above shared sample.
 
Regards, 
Sujith R 



PL Pio Luca Valvona August 10, 2021 03:20 PM UTC

Hi Sujith,

thank you for support.




SK Sujith Kumar Rajkumar Syncfusion Team August 11, 2021 06:03 AM UTC

Hi Pio, 

You’re welcome. Please get back to us if you require any further assistance. 

Regards, 
Sujith R 


Loader.
Up arrow icon