Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How do I get selected node from one tree view to other tree view using javascript or jquery ?

in my design view
ASP.NET
//head Jquery for check and uncheck 
<script>
 $(document).ready(function () {

            $("div[class $= t1] input[type=checkbox]").click(function () {
                $(this).closest("table").next("div").find("input[type=checkbox]").attr("checked", this.checked);
 });


        });

</script>
//body 
<asp:TreeView ID="treeviwExample" class="t1" ShowCheckBoxes="All"  runat="server" ImageSet="Arrows">
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <Nodes>
                <asp:TreeNode Text="Root" Value="Root">
                    <asp:TreeNode Text="Parent1" Value="Parent1">
                        <asp:TreeNode Text="Leaf 1" Value="Leaf 1"></asp:TreeNode>
                        <asp:TreeNode Text="Leaf 2" Value="Leaf 2"></asp:TreeNode>
                    </asp:TreeNode>
                    <asp:TreeNode Text="Parent2" Value="Parent2">
                        <asp:TreeNode Text="Leaf 1" Value="Leaf 1"></asp:TreeNode>
                        <asp:TreeNode Text="Leaf 2" Value="Leaf 2"></asp:TreeNode>
                    </asp:TreeNode>
                </asp:TreeNode>
            </Nodes>
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
            <ParentNodeStyle Font-Bold="False" />
            <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />            
        </asp:TreeView>

 <asp:TreeView ID="TreeViewSelectedData" runat="server">
    </asp:TreeView>


So my doubt is If i check Leaf 1 then i want Leaf 1 along with Parent 1 and Root as below in tree format in 2nd treeview
Root
  Parent 1
     Leaf 1
     Leaf 2

like this if i check leaf 2 of parent 2 then i want to append Parent 2 Leaf 2 like this
Root
  Parent 1
     Leaf 1
     Leaf 2
  Parent 2
     Leaf 1
     Leaf 2


and so on .

So if i do uncheck den the elemnt of the 2nd treeview shud b remove along with its parent node.

And very imp is i want this on Client side Scripting language..
Posted
Updated 8-Aug-12 23:57pm
v3
Comments
ZurdoDev 8-Aug-12 9:52am    
What tree view control are you using? Some 3rd party controls have built-in methods to do that.
Sourav Kumar Panda 9-Aug-12 5:35am    
ASP.net Treeview Control (Navigation Control)
Sandeep Mewara 8-Aug-12 10:00am    
Which treeview control? Did you try anything so far?
Sergey Alexandrovich Kryukov 8-Aug-12 15:08pm    
And what's the problem?
--SA
Sourav Kumar Panda 9-Aug-12 5:35am    
Acutally i m using ASP.NET treeview navigation control.
My Requirement is i hv two asp.net treeview control with check box functionality on my page 1st one is of some data and 2nd is empty one.
So if i check any element in d 1st treeview i want dat element along with its child checked node in to my 2nd treeview which is by default empty and if i uncheck dat 1st treeview checked item den the second checkbox element shud b deleted . I want this requirement only using Client side scripting language (JavaScript/Jquery).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900