I’m trying to change the sortorder in a database table looking like this :
id parentid sitename sortorder
1 0 home 0
2 0 about 1
3 0 product 2
4 0 contact 3
Now when i drag “home” down between “product” and “contact” using jstree, I need to change the sortorder of all 4 sites. The thing i know when I drop the “home” site is the id, parentid and the new sortorder-index, but how would my update linq sql look like to get this to work?
With a Adjacency-Model you do not have much choice, but need to select and then update each sibling.
This will give you all sibblings of this element. Now you need to reorder the result array according to your input. Search for the moved element and move in the array hierarchy.
The update the nodes and you are done with a sortorder (a simple counter should be enough) and you are done.
I could provide you some pseudocode, but ASP is not my language. Hope the idea can help too.
Update
PHP it is.
This will give you a array, where the
index == sortorderand you can update your database records accordingly.UPDATE
$movdeElementFromDB – actual db element that gets moved in request
$el – is one sibling of the current element / result of query above