This is a migrated thread and some comments may be shown as answers.

Expand only selected node client side

3 Answers 129 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tejas Kan
Top achievements
Rank 1
Tejas Kan asked on 13 Sep 2011, 11:52 PM
Hi,
I have this situation where, when I click a button client-side(i.e the button onclick ) event, I would like to use javascript function to expand only those nodes that have been checked(ticked). Rest of the nodes to be collapsed.
I am have tried a lot of diff tent ways however with no success.
Can any one help or show me any other examples of a similar situation.

Thanks in advance

Tejas

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2011, 06:41 AM
Hello Tejas kan,

Try the following client side code to achieve your scenario.
Javascript:
function Expand()
{
  var treeView = $find("<%=RadTreeView1.ClientID%>");
    var allNodes = treeView.get_allNodes();
  var temp;
  for (var i = 0; i < allNodes.length; i++)
      {
temp = allNodes[i];
  if (temp.get_checked())
    {
    temp.expand();
    }
 else
    {
    temp.collapse();
    }
  }
 }

Thanks,
Princy.
0
DEBAL
Top achievements
Rank 1
answered on 19 Mar 2012, 10:05 AM
HI
I have same problem , I have refresh button in my aspx page , now i want to show user after click on refresh button the treeview node expanded  that user last click on treeview before click on refresh button, I have used <asp:button id="refreshbutton" Onclientclick="Expand"/> but not working ,.......
0
Princy
Top achievements
Rank 2
answered on 17 Oct 2012, 09:47 AM
Hi,

Here is the sample code that I tried based on your scenario which works as expected.

JS:
<script type="text/javascript">
 function OnClientClick()
 {
   var treeview = $find("<%=RadTreeView1.ClientID %>");
   treeview.get_selectedNode().expand();
   return false;
 }
</script>

Hope this helps.

Thanks,
Princy.
Tags
TreeView
Asked by
Tejas Kan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
DEBAL
Top achievements
Rank 1
Share this question
or