TreeView - collapsed nodes by default

Get help with using Metro 4 components
Post Reply
sprogs
Posts: 6
Joined: Fri Nov 30, 2018 1:33 pm
Status: Offline

TreeView - collapsed nodes by default

Post by sprogs » Sat Jan 26, 2019 2:29 pm

Hello,

I'm trying to create a tree by generating UL and LI elements, it works great.
However, all nodes are expanded, I would like to add entire branches collapsed by default, how can I do this?
I do not want to use JQuery as much as possible, I create items as HTML or JavaScript elements.

I tried to set the class to empty and hide the subtree by default but it does not work well.

I know that there is an 'expanded' class, but I have not seen a similar 'collapsed' class that would solve the problem.

Best regards

User avatar
olton
Site Admin
Posts: 209
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Sat Jan 26, 2019 4:55 pm

Use attribute data-collapsed="true" for li

sprogs
Posts: 6
Joined: Fri Nov 30, 2018 1:33 pm
Status: Offline

Post by sprogs » Sat Jan 26, 2019 6:06 pm

it works great, thanks

best regards

Post Reply