Custom confirm message

Hi,

I'm looking for an exemple of custom validation message for delete command in a Grid.

I find a lot of exemple pour EJ1 but nothing for EJS2 MVC

Thank you

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team June 27, 2018 01:40 PM UTC

Hi Tommy, 
 
 
Thanks for contacting Syncfusion support. 
  
We have achieved your requirement in actionBegin and toolbarClick event. The actionBegin event will trigger when every grid action begins. Here we have customized the confirmation message in action begin event. Using this you can show the confirmation dialog before saving the edited data.  
 
Refer the below code example  
 
  
[Grid] 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).ActionBegin("begin").ToolbarClick("toolbarClick").Columns(col => 
{ 
 
    . .  . 
 
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render() 
 
<script>  
function begin(args) { 
        if (args.requestType == "save" || args.requestType == "delete") { 
            var grid = document.getElementById("Grid").ej2_instances[0]; 
            var updateMessage = "Are you sure to enter " + args.data.OrderID + " in OrderID and " + args.data.ShipCountry + " in Country" 
            var deleteMessage = "Are you sure to delete the record?"; 
            if (isupdate && args.requestType == "save") { 
                if (confirm(updateMessage)) { 
                    //if yes ,data will save  
                } 
                else 
                    args.cancel = true // if no the data wount save 
            } 
            else 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("Grid").ej2_instances[0]; 
        if (args.item.properties.prefixIcon == "e-update" || args.item.properties.prefixIcon == "e-delete") { 
            isupdate = true 
        } 
 
    } 
 
</script>  
 
Refer the below sample and documentation for your reference:  
 
 
 
 
If you misunderstood your query, please get back to us.  
 
 
 
 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon