How to programatically move multiple selected tasks up or down a list

Given a list like below

1 Item 1

  • 1.1 Item 2
  • 1.2 Item 3
    2 Item 4
  • 2.1 Item 5
  • 2.2 Item 6

I would like to be able to select multiple selected tasks then use button click to move them up and down a multilevel list so as to change their wbs code.
I know I can use the gantt.moveTask to move a task to a new position

I also know that I can use the drad and drop feature

There are various ways of how it might be implemented. But at first, you need to decide what position should tasks get after you reorder them. Should they be moved as one block? Should they save the gap between one another? Or maybe something else?

To reorder multilevel tasks, you need to save their collapse state($open: true parameter), collapse the selected tasks, apply the reorder function and restore their collapse position.

Here is an example where you can reorder multilevel tasks as one block:
And this example shows how to reorder tasks via buttons:

1 Like

Thanks for the response. Will work from there