This is a migrated thread and some comments may be shown as answers.

TreeList delete confirmation

12 Answers 196 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Surf
Top achievements
Rank 1
Surf asked on 30 Sep 2011, 03:30 PM
Hi,

I can successfully delete rows from my TreeList but I need to show the user a popup confirmation box first. I have searched extensively for a solution and cannot find anything.

My code for removing a row is listed below:

protected void OnSettingsTreeListDeleteCommand(object sender, TreeListCommandEventArgs e)
{
    TreeListDataItem treeListDataItem = e.Item as TreeListDataItem;
    TableRow tableRow = e.Item as TableRow;
    if (treeListDataItem != null && tableRow != null)
    {
        string name = tableRow.Cells[3].Text;
        string id = treeListDataItem.GetDataKeyValue("Id").ToString();
        SettingsTreeListDataTable.Rows.RemoveAt(Convert.ToInt32(id));
        PropertyType.GetPropertyType(typeof(Brand)).RemoveSetting(name);
    }
}

I guess I need some kind of java script popup.

Thanks

SurfRat.

12 Answers, 1 is accepted

Sort by
0
Surf
Top achievements
Rank 1
answered on 05 Oct 2011, 07:57 AM
Anyone have any ideas?

Thanks

SurfRat
0
Accepted
Mira
Telerik team
answered on 05 Oct 2011, 10:00 AM
Hello Surf,

I suggest that you use the following template column in order to implement delete with confirmation:
<telerik:TreeListTemplateColumn>
    <ItemTemplate>
        <asp:LinkButton ID="Button1" Text="Delete" OnClientClick="if (!confirm('Are you sure?')) return false;"
            CommandName="Delete" runat="server" />
    </ItemTemplate>
</telerik:TreeListTemplateColumn>

I hope this helps.

Regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Shawn Krivjansky
Top achievements
Rank 1
answered on 19 Oct 2011, 06:24 AM
That solution works fine if you want a "browser confirm" box, but what if we want a RADCONFIRM box??

Like... If I use RADCONFIRM in a 100 of my RadGrids as a standard for my DELETE/CONFIRM process, it looks pretty weird to have this ONE box NOT be a RADCONFIRM because I'm using RadTreeList.

Using the following slightly altered code (to be "radconfirm" from "confirm") does NOT block the execution of the delete (i.e. the DELETE occurs regardless of what you choose...in fact, the DELETE occurs long before the choice is even able to be made.)
<telerik:TreeListTemplateColumn UniqueName="Delete" HeaderText="Delete" HeaderStyle-Width="15"
    ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
    <HeaderTemplate>
        <asp:Image ID="imgheaderDelete" runat="server" ImageUrl="~/images/icons/Cancel.gif" ImageAlign="Middle" />
    </HeaderTemplate>
    <ItemTemplate>
        <asp:ImageButton ID="ibDelete" runat="server" ToolTip="Delete" CommandName="Delete"
            ImageUrl="~/images/icons/Cancel.gif"
            OnClientClick="return radconfirm('Please consider consequences of DELETE action before proceeding. Are you sure?');" />
    </ItemTemplate>
</telerik:TreeListTemplateColumn>

Why don't we have the exact same functionality for a "TreeListButtonColumn" as we do for a "GridButtonColumn" in RadGrid (shown below)??  It would appear this sort of thing would/should have the exact same functionality.  In fact, I can't believe they both aren't built from the same base class with the same base functionality.  Yet, no "confirm" functionality exists on the TreeList side.  Why?
<telerik:GridButtonColumn UniqueName="Delete" CommandName="Delete" ButtonType="ImageButton"
    HeaderText="Delete" Text="Delete Record"
    ImageUrl="~/images/icons/Cancel.gif" HeaderImageUrl="~/images/icons/Cancel.gif" HeaderStyle-Width="15"
    ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
    ConfirmText="Please consider consequences of DELETE action before proceeding."
    ConfirmDialogType="RadWindow" ConfirmTitle="Are you sure?" /> 

So, given it doesn't have the same functionality as a GridButtonColumn, how would one go about using "RadConfirm" in this situation (using my TreeListTemplateColumn as a start...) ??

Thanks.

0
Shawn Krivjansky
Top achievements
Rank 1
answered on 19 Oct 2011, 07:19 AM
After some more digging...
I came across this post/code:
http://www.telerik.com/community/code-library/aspnet-ajax/treelist/delete-with-confirmation.aspx

This is exactly what I was looking for.

However, I would STRONGLY suggest this kind of functionality be wrapped up into "TreeListButtonColumn" just like GridButtonColumn has today....  This is just way too much code that needs to be added for a simple confirmation in TreeList and is SOOOO easy to do with GridButtonColumn in a RadGrid.  Please put this on the list to incorporate for the next version of TreeList.

Thanks.

0
Mira
Telerik team
answered on 21 Oct 2011, 12:52 PM
Hello Shawn,

I have forwarded your request to our developers and they will implement it in the future versions of the RadTreeList.

Thank you for the suggestion.

All the best,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
David
Top achievements
Rank 1
answered on 01 Dec 2011, 04:56 PM
Agreed!  Shawn is right on the money.
0
Maurizio Piaggio
Top achievements
Rank 1
answered on 09 Oct 2012, 10:55 AM
Good morning,
just to know is it been implemented in latest revision?
Thanks
Simone
0
Tsvetina
Telerik team
answered on 12 Oct 2012, 10:25 AM
Hello Simone,

This is not yet available as a built-in feature, as it has been a low priority task. I will note to our developement team that it has been requested again, so they can probably increase its priority and implement it soon.

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 06 Mar 2015, 08:42 PM
This seems like a pretty large omission.  An accidental delete at a root tree node can wipe out a whole structure without any confirmation.  I would also like to see this as a standard feature.
0
Viktor Tachev
Telerik team
answered on 11 Mar 2015, 11:06 AM
Hello John,

The confirmation feature has been implemented and is available out of the box for the TreeListButtonColumn. You can set the text in the confirmation dialog via the ConfirmText property.

If you would like additional information on how the confirmation dialog can be configured you would find the following article interesting.



Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Matthew
Top achievements
Rank 1
Veteran
answered on 27 Feb 2019, 02:51 PM

Is this also available for mvc?

 

0
Marin Bratanov
Telerik team
answered on 04 Mar 2019, 07:26 AM
Hello Matthew,

RadTreeList and the other controls from the UI for ASP.NET AJAX suite are designed for WebForms and are not supported under MVC.

The Kendo TreeList widget that also has an MVC helper does not offer a built-in confirmation dialog, yet you can define a custom command where you can invoke the desired confirmation logic before doing anything with the treelist:

 


Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeList
Asked by
Surf
Top achievements
Rank 1
Answers by
Surf
Top achievements
Rank 1
Mira
Telerik team
Shawn Krivjansky
Top achievements
Rank 1
David
Top achievements
Rank 1
Maurizio Piaggio
Top achievements
Rank 1
Tsvetina
Telerik team
John
Top achievements
Rank 1
Viktor Tachev
Telerik team
Matthew
Top achievements
Rank 1
Veteran
Marin Bratanov
Telerik team
Share this question
or