
Bootstrap Treeview - schniter
https://github.com/chniter/bstreeview
======
bigato
I recently used html5 sumary/detail to implement a treeview and it was the
best experience ever solving such problem on the web. Very simple and easily
customizable via css, and if you render it on the server, you don't need
javascript at all.

~~~
jakearmitage
Any example?

~~~
bigato
Unfortunately I didn't find an example that was simple enough on the web, and
the work I did is not open source, so here is the best link I found, which was
by the way what I used to derive my implementation:

[https://codepen.io/dsheiko/pen/MvEpXm](https://codepen.io/dsheiko/pen/MvEpXm)

This is a bit fancier than necessary and that makes it not so good as an
example for learning, but hopefully it will be enough to give you the idea.

edit: this one is a little bit better to understand the basics:
[https://medium.com/metaphorical-web/javascript-treeview-
cont...](https://medium.com/metaphorical-web/javascript-treeview-controls-
devil-in-the-details-74c252e00ed8)

In short, summary/detail has the native hability to collapse the details and
you can explore that to implement a tree by nesting them.

~~~
bigato
Scratch my post above, I made a better example:

[https://pastebin.com/raw/9D02J80s](https://pastebin.com/raw/9D02J80s)

~~~
lukastyrychtr
Unfortunately, this is missing the semantic metadata about the fact that it's
a tree. It might be fine in some cases, but in general you would want to add
some Aria attributes. But i'm not sure whether you could generate the entire
thing server-side.

------
have_faith
I was surprised to see the markup generated by JS but after initial page
loading the markup doesn't get re-rendered again in any scenario. Seems a
shame to throw away accessibility for a single pass render when the markup
could just already be there.

For anyone interested in rolling their own, nested UL/OL's and jQuery's
slideToggle will get you most of the way there but with better accessibility.

------
The_Colonel
For complex tree views I can recommend FancyTree:

[https://github.com/mar10/fancytree](https://github.com/mar10/fancytree)

------
gamegod
Looks good, Sam! I'm going to tuck this away and use it next time I need a
tree view.

------
LeonB
I had to do such a thing recently and ended up rolling my own mostly server
side rendering in order to avoid loading it all at once.

------
Achshar
No. Just no. Don't install a library and two others just to show a tree view.
Make your own with whatever features you need and just those features, nothing
else. Less than 200 lines of code and one day's work for a competent
developer. Don't install three libraries in your webpage just to show a tree
view.

~~~
phpnode
If you're in the market for a Bootstrap Treeview you're likely already using
Bootstrap and therefore jQuery.

Your comment reflects exactly the kind of attitude that puts people off doing
open source work. No one is forcing you to use this project, someone put
effort into making this and released it to the world for free, what does your
criticism add?

~~~
gamegod
It's a problem with HN - Since the average user can't downvote, these trash
troll comments stay at the top and derail any conversation, when they should
just be insta-downvoted into oblivion.

You're totally right, but everyone should just ignore the idiot troll and move
on.

~~~
robofanatic
There is no way to know if its a troll or a noob or just a kid trying to learn
web development who doesn't know what bootstrap is and has probably heard that
external dependencies are typically bad.

