Skip to content

Multi-drag

With MultiDrag="true" you can click items to select several of them, then drag any one of the selected items to move the whole group together. The selection keeps its order and lands as a contiguous block where you drop it. Click an item to toggle its selection; Shift+click selects a range. This mirrors the SortableJS multi-drag demo.

A single list, with a bound selection

@bind-SelectedItems keeps the selection in step with a field of the page, both ways: the list reports every change, and takes a selection the page sets - the two buttons below just assign the field.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6

Order: Item 1, Item 2, Item 3, Item 4, Item 5, Item 6

Selected: nothing

Last drag moved: nothing yet

Across two lists

Both lists share a group, so a selection made in one can be dragged into the other.

Item 1
Item 2
Item 3
Item 4
Item A
Item B
Item C
Item D

Left: Item 1, Item 2, Item 3, Item 4

Right: Item A, Item B, Item C, Item D

Try it

  • Click Item 2 and Item 5, then drag Item 5 to the top: both land there, together and in their order. The selection is spent by the move, and Last drag moved lists what the drag carried - the event's Items.
  • Click Item 2, then Shift+click Item 5: every item from 2 to 5 is selected.
  • With a few items selected, drag an item that is not selected: the selection is cleared, and only that item moves.
  • Select Item 1 and Item 3 on the left and drag them into the right list.
  • From the keyboard, focus an item and press Shift+Space to select it (it is announced: "Item 2 selected. 1 item selected."); pick a selected item up with Space, and the whole selection moves with the arrows.

Good to know

  • The selection is published in list order, through SelectedItemsChanged, whenever it changes - a click, a range, Shift+Space, a drag that spends it or one that clears it.
  • A selection the page sets leaves out the items that are not in the list, and those a Filter locks. Items that leave the list, or are replaced with the whole Items list, leave the selection too.
  • The selected items wear SelectedClass (bit-bortable-selected by default), drawn with --bit-bortable-selected-bg and --bit-bortable-selected-ring.
  • Combined with a Clone pull, dragging into another list clones only the dragged item. A move made by code (MoveAsync) moves one item and does not carry the selection along.

Parameters on this page

ParameterHereWhat it does
MultiDragtrueClicks select items, and dragging a selected item moves the whole selection.
@bind-SelectedItems_selectedThe selection, to read or set; SelectedItemsChanged reports it.
OnEndOnListDragEndReads Items, every item the drag moved.
An unhandled error has occurred. Reload 🗙