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

Expand ancestors

1 Answer 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 19 Jun 2014, 07:50 AM
Hi,
I have a treeview and a textbox for search. I am able to get the searched node from the treeview. But I need to expand all the ancestors of that node.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2014, 08:00 AM
Hi Alyssa,

Try the following javascript function to expand ancestor nodes.

function expandAllAncestors(node) {
       if (node.get_expanded() !== true)
            node.expand();
           if (node.get_level() != 0) {
               expandAllAncestors(node.get_parent());
           }
       }

Thanks,
Shinu.
Tags
General Discussions
Asked by
Alyssa
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or