RadTreeNode OnClientDoubleClick client event

4 posts, 0 answers
  1. Peter Nanayakkara
    Peter Nanayakkara avatar
    2 posts
    Member since:
    Oct 2008

    Posted 05 Nov 2008 Link to this post

    Hi all,

    I have set the OnClientDoubleClick client side event for the RadTree.
    This client side event will trigger when I double click on the RadTreeNode's text, but not on the RadTreeNode's image icon.

    Is there a way I can also trigger the event when I double click on the icon?

    I tried inspecting the RadTreeNode.Controls property thinking I will able to get a reference to the Image control and can inject my own client side event, but that Controls collection is empty.

    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2008 Link to this post

    Hi Peter,

    Here is a KB article which explains how you can attach events to Treenode images on the client side.
    Attaching events to the TreeNodes' images

    Shinu.

  3. Peter Nanayakkara
    Peter Nanayakkara avatar
    2 posts
    Member since:
    Oct 2008

    Posted 08 Dec 2008 Link to this post

    Thanks Shinu


    Is there no way to do add the event server side?
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 09 Dec 2008 Link to this post

    Hello Peter Nanayakkara,

    No, there is no such possibility. On the code behind you can set only the name of the javascript handler which will fire when the user double clicks the node:

    RadTreeView1.OnClientDoubleClick = "onDoubleClickHandler"

    Here is a different workaround that you can use to in order to fire the double click event when the user double clicks the image of the node:

    Put this code right after the treeview's declaration:

    <script type="text/javascript"
    var init = Telerik.Web.UI.RadTreeView.prototype.initialize; 
    Telerik.Web.UI.RadTreeView.prototype.initialize = function () 
        init.apply(this, arguments); 
        this._eventMap.addHandlerForClassName("dblclick""rtImg"this._doubleClick);   
    </script>      

    This is not a recommended solution though. It overrides the initialize method and uses private members (like _eventMap) which could be changed in the future.

    Use it on your own risk and after you have tested it.

    Kind regards,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top