While I can get the delete confirmation to work, I am unable to use the JavaScript confirm dialog in our environment. I was trying to reproduce the confirm dialog with your MVC Dialog, but I could not figure out how to get it to block the completion of the OnActionBegin event handler like the confirm dialog does without freezing the JavaScript. I opted to cancel the event and then open the MVC Dialog to confirm the delete and then try to programmatically call the grid to delete the row in the OnOK handler of the MVC Dialog. I can't seem to find a method to delete a row in the grid programmatically. Is there a way to do this?
Hi Robert,
Thank you for your interest in Syncfusion products.
We glad to let you know that your requirement can be achieved by using “OnActionBegin” client side event.
Please refer the below code snippets to achieve this.
[Aspx]
1.Created Dialog Box using
Syncfusion Dialog
<div
id="myDialog"
title="Delete
Confirmation Dialog" style="display: none">
Are you sure you want to delete the record?
<input type="button"
id="confrim"
value="Confirm"
/>
<input type="button"
id="cancel"
value="cancel"
/>
</div>
<%=Html.Syncfusion().Dialog("myDialog").MinHeight(10).Height(80).Modal(true).AutoOpen(false)%>
2.ClientsideEvent
.ClientSideEvents(events =>
{
events.OnActionBegin("deleteConfirmation");
})
[javascript]
<script
type="text/javascript">
window.confirmed = false;
function deleteConfirmation(sender, args) {
if
(args.requestType == "Delete") {
$("#myDialog").dialog("open");
if (!window.confirmed)
args.cancel
= true; //
Deletion operation is cancelled to prevent automatic deletion before
confirmation
window.confirmed = false;
}
}
$("#confrim").click(function () {
var gridObj = $find('SampleGrid');
//To get the Grid Object
window.confirmed = true //It is set to true to perform the deletion when delete request is
sent from confirm button
gridObj.sendDeleteRequest(); //Delete Request is
sent when confirm button is clicked
$("#myDialog").dialog("close");
});
$("#cancel").click(function () {
$("#myDialog").dialog("close");
});
</script>
For your convenience, we have prepared a simple sample and the same can be downloaded from the below link.
Sample Link: GridDeleteConfirmDialog.zip
Please check the above sample and let us know if this is helpful.
Regards,
Alan
Sangeeth S