dynamicData
The functionality is available in PRO Edition only
PROEnables on-demand column loading. When turned on, the board starts without card data and requests cards for each column as it becomes visible. The store emits request-data for unloaded columns; your code answers with provide-data.
Usage
dynamicData?: boolean;
false(default) - static mode. All columns are treated as loaded and the fullcardsarray is expected up front.true- dynamic mode. Columns start with adataStatusof"unknown"and the store firesrequest-dataas they become visible. The host fetches data and responds withprovide-datato mark the column"loaded".
Example
import { useState } from "react";
import { Kanban } from "@svar-ui/react-kanban";
const columns = [
{ id: "backlog", label: "Backlog" },
{ id: "doing", label: "In Progress" },
{ id: "done", label: "Done" },
];
function App() {
const [api, setApi] = useState(null);
return (
<Kanban
columns={columns}
dynamicData
cards={[]}
init={obj => setApi(obj)}
onRequestData={async ({ id }) => {
const cards = await fetch(`/api/columns/${id}/cards`).then(r => r.json());
api.exec("provide-data", { id, cards });
}}
/>
);
}
Related
- Working with server - dynamic loading setup with RestDataProvider
- request-data - emitted when a column needs cards loaded
- provide-data - responds with card data for a column