Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I need sample code for expand and collapse for asp treeview ,i use treeview with enable checkbox,if i click the parent node checkbox it expand all child node ,if i uncheck the parent node it collapse the child node,pls reply asap.

Note : not use "+" symbol for expand and collapse,enable the checkbox ture in treeview,using that checkbox only expand and collapse the nodes.In JavaScriipt

Thanx
Aravind
Posted

1 solution

Hi Aravindba,

I have implemented the same in my project once, It reminds me once you asked this question,
will paste my code for you here so that you can make use of it in your code.
C#
container.find("#btn_CollapseAllPennyTests").unbind("click").click(function () {
    //$(".penny-test-group-row").closest("tr").not(":first").not(".Penny-Test-Group-All").hide();
    $(".odd").closest("tr").hide(); 
    $(".even").closest("tr").hide();
});

container.find("#btn_ExpandAllPennyTests").unbind("click").click(function () {
    //$(".penny-test-group-row").closest("tr").not(":first").not(".Penny-Test-Group-All").hide();
    $(".odd").closest("tr").show();
    $(".even").closest("tr").show();
});


I hope this would help you.
 
Share this answer
 
Comments
Aravindba 24-Apr-13 11:41am    
Hai rk_prabakar
Thank u for ur reply,but in need in check enabled treeview,in the parent checkbox is checked it expand all its node and if again unchecked the parent check it collapse the all node.The code send by you may u use 2 buttons ? i am not use buttons for expand and collapse,if enable chekbox treeview all nodes get checkbox,if any node have child node then i click parent node it expand all child node ,if again i uncheck it collapse the parent node.
♥…ЯҠ…♥ 25-Apr-13 1:52am    
For that you should find out the child node class name or id name, with that you may do the same thing that i have done.If you check parent node then all child node under that parent node so you might use toggle() for child nodes i believe.

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