Answer the question
In order to leave comments, you need to log in
How to display a Nested Set tree with a grouping of nodes?
Good afternoon experts.
After a long search for a solution to my problem, I began to delve a little into the Nested Set. I liked the model, it is very convenient to sample data. BUT ran into a problem. Although, perhaps, this is not a problem, but for some reason I cannot figure out how to implement it.
I have a certain tree in the database, for example, the site menu. One type request:
I get the whole tree.
But I want to build the site menu so that the categories and subcategories can be collapsed.
Those. The website menu looks like this:SELECT * FROM my_tree ORDER BY left_key
<ul>
<li>Категория 1
<ul>
<li>Пункт меню 1.1</li>
<li>Пункт меню 1.2</li>
</ul>
</li>
<li>Категория 2
<ul>
<li>Пункт меню 2.1</li>
<li>Пункт меню 2.2</li>
</ul>
</li>
</ul>
Answer the question
In order to leave comments, you need to log in
Tree traversal without recursion , but simply by recursion bypass the records and collect the tree.
I don’t know how to display a menu without cycles, but in order for categories and subcategories to be collapsed, I can advise interesting modules:
https://github.com/dbushell/Nestable - it is quite simple and provides collapse.
https://github.com/RamonSmit/Nestable2 - completion of the upper module with improved ability to set events.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question