client and server click events

2 posts, 0 answers
  1. Ed Staffin
    Ed Staffin avatar
    66 posts
    Member since:
    Nov 2008

    Posted 24 Sep 2009 Link to this post

    Hi,
    I have a couple of treeviews embedded in a radpanel as shown below. I am trying to catch the OnClientNodeClicked event in javascript, however when I add the OnClientNodeClicked="DoOnClientNodeClick
    to the treeview definition I find that my server side event handler no longer gets called.

    Ultimately, what I am trying to do is have the control expand or collapse regarless of whether the click on the plus/minus sign or on the text of the node.
    Any guidance would be greatly appreciated.
    Thanks ... Ed


    Here is the javascript I am using:
            function DoOnClientNodeClick(sender, eventArgs)  
            {  
                var node = eventArgs.get_node();  
                node.toggle();  
                CollapseOthers(node);  
                return true;  
            }  
              
            function DoOnClientNodeExpanded(sender, eventArgs)  
            {  
                eventArgs.get_node().select();  
                CollapseOthers(eventArgs.get_node());  
                return true;  
            }  
            function CollapseOthers(node)  
            {  
                // if they are expanding a node then close all other root nodes  
                if (node.get_expanded())  
                {  
                    var tv = node.get_treeView();  
                    var nodeRoot;  
                    var nCnt = 0;  
                    // find the root node of the clicked on node  
                    while (1)  
                    {  
                        if (node.get_parent() == tv)  
                        {  
                            nodenodeRoot = node;  
                            break;  
                        }  
                        else  
                            nodenode = node.get_parent();  
                          
                        // a just in case check for a runaway loop  
                        if (nCnt++ > 250)  
                            return;  
                    }  
                    var i;  
                    // collapse all other roots  
                    for (i = 0; i < tv.get_nodes().get_count(); i++)  
                    {  
                        if (tv.get_nodes().getNode(i) != nodeRoot)  
                        {  
                            tv.get_nodes().getNode(i).set_expanded(false);  
                        }  
                    }  
                }  
            }  
     



    On the server side I have the following code
        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init  
            Dim tv As RadTreeView = rpiAccounts.FindControl("rtvAccount")  
            AddHandler tv.NodeExpand, AddressOf tvAccounts_NodeExpand  
            AddHandler tv.ContextMenuItemClick, AddressOf rtvAccount_ContextMenuItemClick  
            AddHandler tv.NodeClick, AddressOf rtvAccount_NodeClick  
            AddHandler tv.NodeDrop, AddressOf rtvAccount_NodeDrop  
     
            tv = rpiLevels.FindControl("rtvLevel")  
            AddHandler tv.NodeClick, AddressOf rtvLevel_NodeClick  
        End Sub 

                                    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Vista" ExpandMode="SingleExpandedItem" Width="402px" > 
                                        <CollapseAnimation Duration="100" Type="None" /> 
                                        <Items> 
                                            <telerik:RadPanelItem id="rpiAccounts" runat="server" Text="Accounts">  
                                                <ItemTemplate> 
                                                    <telerik:RadTreeView ID="rtvAccount" runat="server"  EnableDragAndDrop="true" 
                                                         EnableDragAndDropBetweenNodes="true" Skin="Vista" CausesValidation="false" 
                                                         OnClientNodeClicked="DoOnClientNodeClick"

                                                         OnClientNodeExpanded

     

    ="DoOnClientNodeExpanded"

     

                                                         > 
                                                        <CollapseAnimation Duration="100" Type="OutQuint" /> 
                                                        <ExpandAnimation Duration="100"/>  
                                                    </telerik:RadTreeView> 
                                                </ItemTemplate> 
                                            </telerik:RadPanelItem> 
                                            <telerik:RadPanelItem id="rpiLevels" runat="server" Text="Levels">  
                                                <ItemTemplate> 
                                                    <telerik:RadTreeView ID="rtvLevel" runat="server" Skin="Vista" CausesValidation="false"
                                                         OnClientNodeClicked="DoOnClientNodeClick"

                                                         OnClientNodeExpanded

     

    ="DoOnClientNodeExpanded"

     

                                                        >  
                                                        <CollapseAnimation Duration="100" Type="OutQuint" /> 
                                                        <ExpandAnimation Duration="100" /> 
                                                    </telerik:RadTreeView> 
                                                </ItemTemplate> 
                                            </telerik:RadPanelItem> 
                                        </Items> 
                                        <ExpandAnimation Duration="100" Type="None" /> 
                                    </telerik:RadPanelBar> 
  2. Yana
    Admin
    Yana avatar
    4985 posts

    Posted 28 Sep 2009 Link to this post

    Hi Ed,

    I've tested the provided code but couldn't reproduce this issue, the server events are fires without a problem. Could you please open a support ticket and send us a simple page demonstrating the issue there? Thanks in advance

    Greetings,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top