Skip to main content

provide-data

Upserts cards into the store. When id is provided, the cards are assigned to that column via columnAccessor and the column's data status flips to "loaded". Without id, cards are bulk-upserted as-is (used for imports).

If the target column doesn't exist, the action is a no-op.

Usage

type ProvideDataPayload = {
id?: ColumnID;
cards: KanbanCard[];
};
FieldTypeDescription
idColumnID (optional)Column to associate the cards with. When set, each card's column field is written via columnAccessor and the column status becomes "loaded".
cardsKanbanCard[]Cards to add or update. Existing cards with matching id values are updated; new cards are inserted.

Trigger

api.exec("provide-data", {
id: "backlog",
cards: [
{ id: 1, label: "Task one" },
{ id: 2, label: "Task two" },
],
});

Bulk import without a column (cards must already carry their column field):

api.exec("provide-data", {
cards: importedCards,
});

Observe

api.on("provide-data", ev => {
console.log(`Loaded ${ev.cards.length} cards for column ${ev.id}`);
});

Intercept

api.intercept("provide-data", ev => {
// strip cards that fail validation
ev.cards = ev.cards.filter(c => c.label);
});

Component handler

<Kanban
{cards}
{columns}
onprovidedata={(ev) => {
console.log("Cards provided:", ev.cards.length);
}}
/>