i am totally confused with sorting treedata and displaying with bootstrap-treedata.js (https://github.com/jonmiles/bootstrap-treeview). since i am new here, ich hope my question fits in here - i did´nt found any solutions or helpful reference somewhere else.
my raw data looks like:
id: 1, name: Node_1, parent_id: 0, sort: 3
id: 12, name: Child_of_Node_1, parent_id: 1, sort: 2
id: 323, name: Node_2, parent_id: 0, sort: 1
id: 4352, name: Child_of_Node_2, parent_id: 323, sort: 5
id: 7256, name: Child_of_Child_of_Node_1, parent_id: 12, sort: 3
...and so on.
populating on the website works fine. Any efforts to sort the data upfront (seperately by Level according to the field ‚sort’) fails. it will always be displayed sorted by 'id' asc.
Are there any suggestions if I have to use an other library (instead of bootstrap-treeview.js) or if I have to sort the HTML-Output while displaying the website? Or even if the raw data could somehow be sorted successfully upfront?
Thanks folks!
Finally I found out myself, just in case this helps someone: the treedata can be sorted with the database query. In my case, and I assume this could also work on other libs displaying treedata, it was vital to sort the data of all nodes. Sorting only the top node hadn‘t helped.