cards
Description
Optional. An array of objects holding the cards data
Usage
cards?: [
{
id?: string | number,
label?: string,
description?: string,
progress?: number,
start_date?: Date,
end_date?: Date,
attached?: [
{
id: string | number,
url?: string,
previewURL?: string,
coverURL?: string,
name?: string,
isCover?: boolean
size?: number
}, {...}
],
color?: string,
users?: array | string | number,
// users?: array - for multiple users, if you use the "multiselect" editor type to assign users
// users?: string | number - for a single user, if you use the "combo" or "select" editor type to assign a user
priority?: string | number,
css?: string,
votes?: array,
comments?: [
{
id: string | number,
userId: string | number,
cardId: string | number,
text?: string,
date?: Date,
}, {...}
],
[custom_key: string]?: any
}, {...} // other cards data
];
Parameters
Each card can include the following parameters (data):
id- (optional) the card's ID. This is used for managing the card through related methodslabel- (optional) the card's label, shown in the Label fielddescription- (optional) a description for the card, displayed in the Description fieldprogress- (optional) progress bar value from 0 to 100. Displayed in the Progress bar fieldstart_date- (optional) a Date object representing the start date (avoid using string dates). Shown in the Start date fieldend_date- (optional) a Date object representing the end date (avoid using string dates). Shown in the End date fieldattached- (optional) an array of objects representing attached files. Shown in the Attachment field. Each object can include:id- (required) the ID of the attached fileurl- (optional) the file pathpreviewURL- (optional) path to the preview imagecoverURL- (optional) path to the cover imagename- (optional) file nameisCover- (optional) if true, sets the cover image using the "coverURL"size- (optional) file size in bytes
color- (optional) a HEX color code, which sets the color of the card's top lineusers- (optional) either an array of user IDs for multiple assigned users or a string | number for a single assigned user. To assign users, define an array of user data in the cardShape.users property. These users appear in the Users field
info
users?: array - use an array of user IDs when using the multiselect editor type to assign multiple users
users?: string | number - use a single ID when using the combo or select editor types to assign one user
priority- (optional) the card's priority ID. Define an array with priority data in the cardShape.priority property. Displayed in the Priority fieldcss- (optional) custom CSS styles for the individual cardvotes- (optional) an array of user IDs representing votescomments- (optional) an array of comment objects. Each comment can have:id- (required) the comment's IDuserId- (required) user ID who posted the commentcardId- (required) the card's ID the comment belongs totext- (optional) the comment text, which may include HTML markupdate- (optional) a Date object representing when the comment was posted (not updated after edits)
custom_key- (optional) custom keys for placing the card into specific columns or rows. See columnKey and rowKey properties
info
To dynamically load new card data, you can use the parse() method!
Example
const cards = [
{
id: 1,
label: "Integration with React",
description: "Some description",
progress: 25,
start_date: new Date("02/24/2022"),
end_date: new Date("02/24/2023"),
attached: [
{
id: 234,
url: "../assets/img-1.jpg",
previewURL: "../assets/img-1.jpg",
coverURL: "../assets/img-1.jpg",
name: "img-1.jpg",
isCover: true,
size: 11979
}, {...} // other attached files data
],
color: "#65D3B3",
users: [1,2],
votes: [3,6,8],
comments: [
{
id: 1,
userId: 1,
cardId: 1,
text: "Greetings, fellow colleagues. I would like to share my insights on this task. I reckon we should deal with at least half of the points in the plan without further delays. ",
date: new Date(),
}, {...} // other comments
],
priority: 1,
// custom field to place the card into the "feature" row
// the rowKey config needs to be set to the "type" value
type: "feature",
// custom field to place the card into the "backlog" column
// the columnKey config needs to be set to the "stage" value
stage: "backlog",
css: "red",
}, {...} // other cards data
];
new kanban.Kanban("#root", {
columns,
cards,
// other parameters
});
Change log: The css, comments, and votes parameters were introduced in v1.4
Related articles:
Related sample: Kanban. Styling cards