I have treelists with two levels of items (titles and positions). The titles can be rearranged via drag&drop. Dragging a title onto another title changes the order of titles. Positions can both be dragged under the same title but also to an other title.
- Dragging title 4 onto title 2 makes title 4 the new title 2, title 2 becomes title 3 and title 3 becomes title 4. All subitems (positions) stay with their titles.
- Dragging position 4 in title 3 (3.4) onto position 2 in title 3 (3.2) makes 4 the new 2 (3.2), 2 the new 3 (3.3) and 3 the new 4 (3.4).
- Dragging position 4 in title 3 (3.4) onto position 2 in title 2 (2.2) makes 4 the new 2 in title 2 (2.2), 2 in title 2 the new 3 in title 2 (2.3) and position 5 in title 3 (3.5) the new position 4 in title 3 (3.4).
To do this (see code in attachment) I manipulate the title field and the parentId of the datasource. This worked fine as long as I dirctly saved items that were added to the list. But now I have to use batch save.
Now when I add a new title to the list and add or rearrange positions to that title or rearrange titles via drag&drop before saving the affectet titles and positions are attached to wrong parent items, sometimes items get duplicated. Doing the same thing after saving works as intended.
I assume the reason for this is that new items have an Id of 0 before saving.
I see that it is possible to rearrange items in treelists via drag & drop in your demos without manipulating these fields manually. But I don't see how can do this and get the same results as in the examples above. Could you please help me figure this out?
Note: in the attached files I have included sampledata as local data. In the project we bind to remote data. Not sure if this affects the beavior