|
| 1 | +--- |
| 2 | +sidebar_label: cards |
| 3 | +title: cards Config |
| 4 | +description: Explore the cards configuration in the DHTMLX JavaScript Kanban library documentation. Check out developer guides, API references, try live demos and code examples, and download a free 30-day trial of DHTMLX Kanban. |
| 5 | +--- |
| 6 | + |
| 7 | +# cards |
| 8 | + |
| 9 | +### Description |
| 10 | + |
| 11 | +@short: Optional. An array of objects holding the cards data |
| 12 | + |
| 13 | +### Usage |
| 14 | + |
| 15 | +~~~jsx {} |
| 16 | +cards?: [ |
| 17 | + { |
| 18 | + id?: string | number, |
| 19 | + label?: string, |
| 20 | + description?: string, |
| 21 | + progress?: number, |
| 22 | + start_date?: Date, |
| 23 | + end_date?: Date, |
| 24 | + attached?: [ |
| 25 | + { |
| 26 | + id: string | number, |
| 27 | + url?: string, |
| 28 | + previewURL?: string, |
| 29 | + coverURL?: string, |
| 30 | + name?: string, |
| 31 | + isCover?: boolean |
| 32 | + size?: number |
| 33 | + }, {...} |
| 34 | + ], |
| 35 | + color?: string, |
| 36 | + users?: array | string | number, |
| 37 | + // users?: array - for multiple users, if you use the "multiselect" editor type to assign users |
| 38 | + // users?: string | number - for a single user, if you use the "combo" or "select" editor type to assign a user |
| 39 | + priority?: string | number, |
| 40 | + css?: string, |
| 41 | + votes?: array, |
| 42 | + comments?: [ |
| 43 | + { |
| 44 | + id: string | number, |
| 45 | + userId: string | number, |
| 46 | + cardId: string | number, |
| 47 | + text?: string, |
| 48 | + date?: Date, |
| 49 | + }, {...} |
| 50 | + ], |
| 51 | + [custom_key: string]?: any |
| 52 | + }, {...} // other cards data |
| 53 | +]; |
| 54 | +~~~ |
| 55 | + |
| 56 | +### Parameters |
| 57 | + |
| 58 | +Each card can include the following parameters (data): |
| 59 | + |
| 60 | +- `id` - (optional) the card's **ID**. This is used for managing the card through related methods |
| 61 | +- `label` - (optional) the card's label, shown in the **Label** field |
| 62 | +- `description` - (optional) a description for the card, displayed in the **Description** field |
| 63 | +- `progress` - (optional) progress bar value from 0 to 100. Displayed in the **Progress bar** field |
| 64 | +- `start_date` - (optional) a Date object representing the start date (avoid using string dates). Shown in the **Start date** field |
| 65 | +- `end_date` - (optional) a Date object representing the end date (avoid using string dates). Shown in the **End date** field |
| 66 | +- `attached` - (optional) an array of objects representing attached files. Shown in the **Attachment** field. Each object can include: |
| 67 | + - `id` - (required) the **ID** of the attached file |
| 68 | + - `url` - (optional) the file path |
| 69 | + - `previewURL` - (optional) path to the preview image |
| 70 | + - `coverURL` - (optional) path to the cover image |
| 71 | + - `name` - (optional) file name |
| 72 | + - `isCover` - (optional) if **true**, sets the cover image using the "coverURL" |
| 73 | + - `size` - (optional) file size in bytes |
| 74 | +- `color` - (optional) a HEX color code, which sets the color of the card's top line |
| 75 | +- `users` - (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](api/config/js_kanban_cardshape_config.md) property. These users appear in the **Users** field |
| 76 | + |
| 77 | +:::info |
| 78 | +`users?: array` - use an **array** of user **ID**s when using the [**multiselect**](api/config/js_kanban_editorshape_config.md#--parameters-for-combo-select-and-multiselect-types) editor type to assign multiple users |
| 79 | + |
| 80 | +`users?: string | number` - use a single **ID** when using the [**combo** or **select**](api/config/js_kanban_editorshape_config.md#--parameters-for-combo-select-and-multiselect-types) editor types to assign one user |
| 81 | +::: |
| 82 | + |
| 83 | +- `priority` - (optional) the card's priority **ID**. Define an array with priority data in the [cardShape.priority](api/config/js_kanban_cardshape_config.md) property. Displayed in the **Priority** field |
| 84 | +- `css` - (optional) custom CSS styles for the individual card |
| 85 | +- `votes` - (optional) an array of user IDs representing votes |
| 86 | +- `comments` - (optional) an array of comment objects. Each comment can have: |
| 87 | + - `id` - (required) the comment's **ID** |
| 88 | + - `userId` - (required) user **ID** who posted the comment |
| 89 | + - `cardId` - (required) the card's **ID** the comment belongs to |
| 90 | + - `text` - (optional) the comment text, which may include HTML markup |
| 91 | + - `date` - (optional) a Date object representing when the comment was posted (not updated after edits) |
| 92 | +- `custom_key` - (optional) custom keys for placing the card into specific columns or rows. See [columnKey](../js_kanban_columnkey_config) and [rowKey](api/config/js_kanban_rowkey_config.md) properties |
| 93 | + |
| 94 | +:::info |
| 95 | +To dynamically load new card data, you can use the [**parse()**](api/methods/js_kanban_parse_method.md) method! |
| 96 | +::: |
| 97 | + |
| 98 | +### Example |
| 99 | + |
| 100 | +~~~jsx {1-41,45} |
| 101 | +const cards = [ |
| 102 | + { |
| 103 | + id: 1, |
| 104 | + label: "Integration with React", |
| 105 | + description: "Some description", |
| 106 | + progress: 25, |
| 107 | + start_date: new Date("02/24/2022"), |
| 108 | + end_date: new Date("02/24/2023"), |
| 109 | + attached: [ |
| 110 | + { |
| 111 | + id: 234, |
| 112 | + url: "../assets/img-1.jpg", |
| 113 | + previewURL: "../assets/img-1.jpg", |
| 114 | + coverURL: "../assets/img-1.jpg", |
| 115 | + name: "img-1.jpg", |
| 116 | + isCover: true, |
| 117 | + size: 11979 |
| 118 | + }, {...} // other attached files data |
| 119 | + ], |
| 120 | + color: "#65D3B3", |
| 121 | + users: [1,2], |
| 122 | + votes: [3,6,8], |
| 123 | + comments: [ |
| 124 | + { |
| 125 | + id: 1, |
| 126 | + userId: 1, |
| 127 | + cardId: 1, |
| 128 | + 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. ", |
| 129 | + date: new Date(), |
| 130 | + }, {...} // other comments |
| 131 | + ], |
| 132 | + priority: 1, |
| 133 | + // custom field to place the card into the "feature" row |
| 134 | + // the rowKey config needs to be set to the "type" value |
| 135 | + type: "feature", |
| 136 | + // custom field to place the card into the "backlog" column |
| 137 | + // the columnKey config needs to be set to the "stage" value |
| 138 | + stage: "backlog", |
| 139 | + css: "red", |
| 140 | + }, {...} // other cards data |
| 141 | +]; |
| 142 | + |
| 143 | +new kanban.Kanban("#root", { |
| 144 | + columns, |
| 145 | + cards, |
| 146 | + // other parameters |
| 147 | +}); |
| 148 | +~~~ |
| 149 | + |
| 150 | +**Change log:** The ***css***, ***comments***, and ***votes*** parameters were introduced in v1.4 |
| 151 | + |
| 152 | +**Related articles:** |
| 153 | +- [Working with data](guides/working_with_data.md) |
| 154 | +- [updateCard()](api/methods/js_kanban_updatecard_method.md) |
| 155 | + |
| 156 | +**Related sample:** [Kanban. Styling cards](https://snippet.dhtmlx.com/qu6rpktk?tag=kanban) |
0 commit comments