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

Common delete script for every MVC grid

I have implemented the suggestion from this site where we delete the record from the grid.

In the view:



<div class="Status" style="color: red; font-family: 'Times New Roman'">


<div id="lookupDeleteDialog" title="Delete Lookup Confirmation" style="display: none">

Are you sure you want to delete the record?

<input type="button" id="confrimLookupDelete" value="Delete" />

<input type="button" id="cancelLookupDelete" value="Cancel" />


And my script is

//Deleting a record from a grid

window.confirmed = false;

function deleteConfirmation(sender, args) {

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

if (currentLookupData.IsDefault == true) {

$(".Status").html("'" + currentLookupData.Value + "' is the Default value, so it can not be deleted.");

args.cancel = true;


else {


if (!window.confirmed)

args.cancel = true; // Deletion operation is cancelled to prevent automatic deletion before confirmation

window.confirmed = false;

countLookups = sender._totalRecordsCount;





$(document).ready(function () {

$("#confrimLookupDelete").click(function () {

var da = $find('lookupGrid');//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



$("#cancelLookupDelete").click(function () {




It works fine, however I want it to  be used for each grid in my project, therefore I need to have a way to dynamically call that grid in the script (in place of var da = $find('lookupGrid'))

I have tried to use var gridObj = $find('.Syncfusion-Grid-Core') but it returns a null object. What do you suggest?


2 Replies

YK Yulia Klimov December 13, 2013 04:15 PM UTC

Never mind!

this is what I did:

var gridname = null;

gridname = sender._ID;

var gridObj = $find(gridname) //To get the Grid Object


PS Prabu Sarvesan Syncfusion Team December 16, 2013 06:32 AM UTC

Hi Yulia,

Thanks for your interest in Syncfusion products.

The solution for your query “dynamically call the grid in the script” has been achieved using window object. To achieve this assign grid id in window object and access this window object wherever you needed in the script.

For your convenience we have shown the code snippets below,

Code Snippet:

function deleteConfirmation(sender, args)


      window.gridId = sender.get_ID();    //store current grid Id in window object



$("#confrim").click(function ()


       var gridID = window.gridId;      //get current grid Id

       var gridObj = $find(gridID);     //find current grid object




Please let us know if you need any further assistance.


Prabhu Sarvesan

Live Chat Icon For mobile
Up arrow icon