How to cause click event of a node

2 posts, 0 answers
  1. Bill
    Bill avatar
    1 posts
    Member since:
    Mar 2014

    Posted 03 Mar 2014 Link to this post

    I have a RadDropDownTree and a RadTreeView on the same page.  Basically, a list of messages are being loaded on the page when a category is selected.  The layout of this app requires that the treeview be displayed in a dropdown instead of the traditional treeview.  Since I already have the radtreeview successfully executing all of the code I want it to when a node is selected, I was hoping to fire that code when a selection is made on the raddropdowntree.  Right now, I have some code in javascript which causes a category to get selected in the radtreeview whenever the same cayegory is selected in the raddropdowntree.  However, it seems that the radtreeview node is getting selected with this code, but it is not getting clicked.  The messages do not get loaded the same way they would if someone were to explicitly click on the radtreeview node.

    Here is my javascript which causes the readtreeview category to get selected when the same raddropdown is selected.  Does anyone know how I can make it not just select the node, but also click on the node?

    <script type="text/javascript">
            function OnClientDropDownClosed1(sender, eventArgs) {
                var tree = $find("ctl00_MainContent_MessageList1_MessageFilter1_RadDropDownTree1");
                var entries = tree.get_entries();
                var selectedText = tree.get_selectedText();
                document.getElementById("ctl00_MainContent_CategoryTree1_hfCategoryNum").value = selectedText;
     
                SelectNode(selectedText);
     
            }
     
            function SelectNode(nodeName) {         
                var tree = $find("ctl00_MainContent_CategoryTree1_TreeViewDirectory");
                var node = tree.findNodeByText(nodeName);
                tree.trackChanges();  
                node.set_selected(true);           
                tree.commitChanges();           
                   
            }
     
    </script>
     
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2014 in reply to Bill Link to this post

    Hi Bill,

    Please have a look into the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadDropDownTree ID="RadDropDownTree1" runat="server" DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" DataSourceID="SqlDataSource1" OnClientDropDownClosed="OnClientDropDownClosed1">
    </telerik:RadDropDownTree>
    <telerik:RadTreeView ID="RadTreeView1" runat="server" DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" DataSourceID="SqlDataSource1" OnClientNodeClicked="OnClientNodeClicked1">
    </telerik:RadTreeView>

    JavaScript:
    <script type="text/javascript">
        function OnClientDropDownClosed1(sender, eventArgs) {
            var tree = $find("<%=RadDropDownTree1.ClientID %>");
            var entries = tree.get_entries();
            var selectedText = tree.get_selectedText();
            SelectNode(selectedText);
        }
        function SelectNode(nodeName) {
            var tree = $find("<%=RadTreeView1.ClientID %>");
            var node = tree.findNodeByText(nodeName);
            alert(nodeName);
            tree.trackChanges();
            node.set_selected(true);
            OnClientNodeClicked1(tree,nodeName);
            tree.commitChanges();
     
        }
        function OnClientNodeClicked1(sender, args) {
            alert("clicked event of RadTreeView");
        }
    </script>

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top