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

Confirm delete from GridGroupingControl

GridGroupingControl v7.203.0.37

What is the recommended method of prompting the user to confirm an action taken (ie: Delete) on a row in the GridControl when using the GridRowEditUpdateLink control?

If using an , I would add a handler to the OnClick event to "return confirm('Are you sure you want to delete?')". The GridRowEditUpdateLink has a "Click" event that I could use in the same manner, but there does not appear to be any way to add a handler for the event.

There is an GridRowEditUpdateEventArgs class, but no corresponding GridRowEditUpdateLinkClickEventHandler. Also, a named GridRowEditUpdateLink control (ie: GridRowEditUpdateLink1) does not show up in intellisense in the code-behind, so I cannot see what class members are available for use.

7 Replies

RP Rekha P Syncfusion Team July 16, 2009 01:12 PM UTC

Hi John,

Thank you for your interest in Syncfusion Products.

We suggest you to enable client side confirmation while deleting the data using GridRowEditUpdateLink ItemTemplate. Please refer the code snippet below to achieve this.



DeleteLinkText="Delete" ShowDeleteLink="true" ShowEditLink="True" runat="server"
CssClass="GridRowEditUpdateTemplate" />






- Add a css class to GridRowEditUpdateLink in order to tag the Delete link.
- Using JQuery, tag the class name for click event.
- Check for the clicked link as "Delete" which is given for DeleteLinkText.
- Return the confirmation.

Refer a sample below which illustrates the above.
http://files.syncfusion.com/support/GGC.Web/7.2.0.37/56853/main.htm

Since, the GridRowEditUpdateLink is embedded as ItemTemplate, we need to access its properties and events by finding the TemplateControls through RowDataBound event using FindControl method. Refer the below code snippet which illustrates this.

void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)
{
if (e.Element.Kind == DisplayElementKind.Record)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
//"Template" is the column name for GridRowEditUpdateLink template.
if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Template")
{
GridRowEditUpdateLink = (GridRowEditUpdateLink)e.Row.Cells[i].FindControl("GridRowEditUpdateLink1");
if (GridRowEditUpdateLink != null)
{
GridRowEditUpdateLink.Click += new EventHandler(GridRowEditUpdateLink_Click);
}
}
}
}
}

void GridRowEditUpdateLink_Click(object sender, GridRowEditUpdateEventArgs e)
{
switch (e.CommandLinkType)
{
case "Delete":
//your code
break;
}
}


Let me know if these helps you out.

Thanks,
Rekha


JT John Taylor July 16, 2009 08:17 PM UTC

Hell Rekha,

Thank you for the example. However, the example does not prompt for a delete. I presumed it was supposed to?


BM Balaji M Syncfusion Team July 20, 2009 02:07 PM UTC

Hi John,

Thank your for your interest in Syncfusion Products.

We are sorry for the inconvenience caused.

Please refer the javascript code snippet below to achieve this.



Please refer the updated sample from below link.
http://files.syncfusion.com/support/GGC.Web/7.2.0.37/88127/main.htm


Please let me know if you have any concerns.

Regards,
M. Balaji


MK Martin Kappl November 3, 2009 01:34 PM UTC

Any news on that problem? It´s still not working that way.

And I´am shocked, that this should be the only way to achieve a simple delete confirmation...


RP Rekha P Syncfusion Team November 4, 2009 12:23 PM UTC

Hi Martin,

I am afraid that I am unable to reproduce the stated issue with the previous updated sample. Could you please try to reproduce it in the above sample and sent us detailed reproducing steps, so that we could able to sort out the cause of the issue and provide you a solution?

Kindly let me know if you have any questions.

Thanks,
Rekha


MK Martin Kappl November 11, 2009 10:16 AM UTC

This line of code is not working for us:

if (e.srcElement.innerText == "Delete") ...

In our case innerText is null, because we are not using the text but an icon.

I changed the JavaScript to look for the icon rather than the text and it works.

But it would be nice, if the grid could support a delete message out of the box without "hacks" like this.

But thanks for the support.


GM Gowri Manohari D Syncfusion Team November 12, 2009 06:24 AM UTC

Hi Martin,

Sorry for the inconvenience caused to you.

We have created sample for your requirement. The sample which already provided you works only when we add "DeleteLinkText". Thats why you could not get the solution. We have modified the sample and mentioned the link here. Please check it.

http://files.syncfusion.com/support/GGC.Web/7.3.0.20/F88127/Sample.zip

Let me know the above sample helps you out.

Regards,
Gowri

Loader.
Live Chat Icon For mobile
Up arrow icon