TreeList delete confirmation

11 posts, 1 answers
  1. Surf
    Surf avatar
    9 posts
    Member since:
    Sep 2011

    Posted 30 Sep 2011 Link to this post

    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.

  2. Surf
    Surf avatar
    9 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    Anyone have any ideas?

    Thanks

    SurfRat
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Mira
    Admin
    Mira avatar
    1124 posts

    Posted 05 Oct 2011 Link to this post

    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
  5. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 19 Oct 2011 Link to this post

    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.

  6. Shawn Krivjansky
    Shawn Krivjansky avatar
    86 posts
    Member since:
    Jan 2010

    Posted 19 Oct 2011 Link to this post

    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.

  7. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 21 Oct 2011 Link to this post

    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
  8. David
    David avatar
    1 posts
    Member since:
    Aug 2011

    Posted 01 Dec 2011 Link to this post

    Agreed!  Shawn is right on the money.
  9. Maurizio Piaggio
    Maurizio Piaggio avatar
    13 posts
    Member since:
    May 2007

    Posted 09 Oct 2012 Link to this post

    Good morning,
    just to know is it been implemented in latest revision?
    Thanks
    Simone
  10. Tsvetina
    Admin
    Tsvetina avatar
    1873 posts

    Posted 12 Oct 2012 Link to this post

    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.
  11. John
    John avatar
    2 posts
    Member since:
    Jan 2015

    Posted 06 Mar 2015 in reply to Tsvetina Link to this post

    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.
  12. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 11 Mar 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017