-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree rebuilding problem #2
Comments
Hello, These are examples in tests folders In case you want quick fix you can compare with those code. ............................ However, Do you have sample DB data for run on my side to check and test? Do you use This class don't have If you call |
I have already added this class method myself. Taking as a basis the work of the class (when rebuilding the tree, an array of data is obtained based on the position of the element). |
And to display the tree, I use a very simple query. |
Your method uses data based on element position: getTreeWithChildren. |
The position number is based on the same level only. That means if you have 1.1 that is under parent Root 1, its position must be always start from 1. I have added the sample code of management that is included Create/Read/Update/Delete. I've tested and everything work as expect but please read the note about manually process position number. |
Thank you. But I will have to do all the same automatic change of positions within the same level. |
I found the problem. When getting an array for position renumbering, I forgot to do the sorting. Added and everything worked as it should. So you can add this method to the class to automatically rebuild the position within the same level. |
` ` |
Thank you for your participation but I couldn't use that code because some reasons.
I've tried to create that before but in the end, it will not work if some JS send weird data and it looks like the position can be update in many ways. Thanks again. |
The query is really built not on pure \PDO, but on the query builder (php \PDO basis). But I can help with sql: I send the element id, position number and parent element number to the function. |
When setting the position higher, the remaining elements are shifted out of position order
How to make the rebuild work correctly?
Insert new element
$this->tree->reBuildPosition($insert_id, (int)$data['bra_pos'], $parent); $this->tree->rebuild();
Update element:
$this->tree->reBuildPosition($id, (int)$data['bra_pos'], $parent); $this->tree->rebuild();
The text was updated successfully, but these errors were encountered: