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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Common delete script for every MVC grid

Thread ID:





114921 Dec 13,2013 03:40 PM UTC Dec 16,2013 06:32 AM UTC ASP.NET MVC (Classic) 2
Tags: Grid
Yulia Klimov
Asked On December 13, 2013 03:40 PM UTC

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?


Yulia Klimov
Replied On 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


Prabhu Sarvesan [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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