Skip to main content

move-card

Moves a card to a different column, reorders it within the same column, or both. With swimlanes (PRO), it can also move the card to a different lane.

Usage​

api.exec("move-card", {
id: CardID,
column?: ColumnID,
swimlane?: SwimlaneID,
before?: CardID | null,
});
FieldTypeDescription
idstring | numberID of the card to move. Required.
columnstring | numberTarget column ID. When omitted, the card stays in its current column.
swimlanestring | numberTarget swimlane ID (PRO). When omitted, the card stays in its current lane.
beforestring | number | nullPlace the card before this card in source order. null moves it to the end. Omit to append.

The store rejects the move when:

  • id doesn't match any card
  • column or swimlane doesn't match any configured column or lane
  • before points to a card outside the target column (the card can be in any lane of that column)
  • an object columnAccessor or swimlaneAccessor returns from set a card that doesn't read back as the target column or lane

For a rejected move, the store handler returns false and leaves card data and order unchanged. The action isn't forwarded to data providers or on… props, such as onMoveCard.

An object accessor's set receives a shallow copy of the card, so it can modify and return that copy. When history is on, a move that changes both the column and the lane is one undo step.

Trigger​

// Move card 3 to the "done" column, at the end
api.exec("move-card", { id: 3, column: "done", before: null });

// Reorder card 3 before card 7 within the same column
api.exec("move-card", { id: 3, before: 7 });

// Move card 3 to the "done" column and the "urgent" lane (PRO)
api.exec("move-card", { id: 3, column: "done", swimlane: "urgent" });

Observe​

api.on("move-card", ({ id, column, before }) => {
console.log(`Card ${id} moved to column ${column}`);
});

Intercept​

// Prevent cards from moving into the "done" column
api.intercept("move-card", ({ column }) => {
return column !== "done";
});

Component handler​

<Kanban
cards={cards}
columns={columns}
onMoveCard={({ id, column }) => {
console.log(`Card ${id} moved to ${column}`);
}}
/>