Answer the question
In order to leave comments, you need to log in
How to change order in Adjacency list model?
I implement my tree with dnd on backbone + marionette. Backend - Laravel.
Structure in the database and filling:
How it looks on the frontend:
At the moment, there is no field responsible for the order in the database.
Interested in the implementation of reordering on the backend side. The only option that comes to mind is:
for example, we take a branch (I will immediately indicate the values \u200b\u200bof the order (rank, sort - whatever) field in square brackets)
- Itaque a veritatis. [1]
- - Node 3 - 1 [1]
- - Node 3 - 2 [2]
- - Node 3 - 3 [3]
- - Node 3 - 4 [4]
And we want to drag Node 3 - 4 to a position before Node 3 - 1. We set Node 3 -1 order equal to 1, and for all subsequent nodes we recalculate order + 1. But here the question arises, what if there are many nodes at the same level. In general, I do not know how to approach this issue.
Answer the question
In order to leave comments, you need to log in
for trees you need to use nested set devacademy.ru/posts/nested-set
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question