Persistent drag and drop tree with jQuery, PHP and MySQL – CRUD
Many people asked me how to implement the basic CRUD functionalities for the D&D Tree, so here it is:
Download persistentTreeCRUD.zip
I use the simpletree callback function afterDblClick for the modify functionality, and a simple jQuery click for add and delete. I also used nyroModal for the popup windows.
In this example i reload the page when a CRUD operation is performed, a better implementation should use ajax to modify the tree on the fly.
Is not perfect but it works
Enjoy!

josh
If you delete a category it returns:
Fatal error: Call to a member function MoveNext() on a non-object in D:blabladelete.php on line 17
Clues to fix it?
Mauro
Ops, sorry about that…
just delete the line 16: $relatedCategory->MoveNext();
ramji
Hi,
Please send me the add/modify/delete example
Ramji
Mauro
You can find it here: http://www.mdgart.com/jQuery/Simple-Persistent-TreeCRUD/persistentTreeCRUD.zip
E-Finity
Is it possible if I place a node on a node that immediately gets into a folder?
When I have everything on 1 level I must stand one page at a sub to have. Then I can just hang in there an existing page and delete the already created page.
My excuse for my lack english
Mauro
Sorry, i’m not sure that I understood your question…
skanda
I think E-Finity refer to problem I have too.
If you drag a child on an other child it doesn’t become a parent. Categories with children have a folder as icon and you can drag in other folders or files, but if u drag a file on an other file the last doesn’t become a folder. Btw, thanks for your time and your work. I’m definitely gonna buy you a coffee
Skanda
I think E-finity has my same problem. Let say, to make it easier, that categories with children are folders (as their icon) and categories without are files (as their icon). If you drag a file on an other file, the last one doesn’t become a folder.
So if a folder has been empty it becomes a file and it can not be a folder again.
Btw, thanks for your time and your work. I’m definitely buy you a coffe
luca
Hi Mauro, thanks a lot for your script, I downloaded your source with CRUD!
It delete and rename categories correctly but if I want to add a category it says in popup:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order) FROM category WHERE parent_id = 2' at line 1and if I want to “rearrange” it says:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order = 1 WHERE category_id = 1' at line 1. Can I ask you where can be the problem, I’m going crazy!Luca
luca
excuse me mauro, I’ve wrong for a letter in minus. It’s all ok.
Saqib Aziz
@E-Finity
In persistentTree.php, set docToFolderConvert to true. By default it is false. Setting it to true allows you to move a node into another to get parent-child thing.