Skip to main content

move-column

Moves a column to a new position in the board's column order. Handles column reordering from the UI and from code. Only the column configuration changes. Cards stay in their columns, and the editor stays as it is.

Usage​

type MoveColumnPayload = {
id: ColumnID;
before?: ColumnID | null;
};
FieldTypeDescription
idstring | numberThe column to move
beforestring | number | nullThe column to place it in front of. Omitted, null, or an unknown id appends it to the end

The action is a no-op when id matches no column, when before is the column itself, or when the move leaves the column at its current index. A no-op keeps the undo/redo history. A move that changes the order resets both history stacks.

Trigger​

// place "done" in front of "doing"
api.exec("move-column", { id: "done", before: "doing" });

// move "backlog" to the end
api.exec("move-column", { id: "backlog" });

Observe​

api.on("move-column", ev => {
console.log("Column moved:", ev.id, "before", ev.before);
});

Intercept​

api.intercept("move-column", ev => {
// keep the "backlog" column in place
if (ev.id === "backlog") return false;
});

Component handler​

Kanban forwards the action to the onmovecolumn prop.

<Kanban
:cards="cards"
:columns="columns"
:onmovecolumn="(ev) => console.log('Column moved:', ev.id)"
/>