Skip to content

Commit 59a1ec9

Browse files
[update] the columnShape property (v2.0)
1 parent ffd32f7 commit 59a1ec9

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

docs/api/config/js_kanban_columnshape_config.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ columnShape?: {
2828
] | ({ column, columnIndex, columns, store }) => array | boolean
2929
},
3030
fixedHeaders?: boolean,
31-
css?: (column, cards) => string
31+
css?: (column, cards) => string,
32+
headerTemplate?: template(column => {
33+
return "The HTML template of the column header in the expanded state";
34+
}),
35+
collapsedTemplate?: template(column => {
36+
return "The HTML template of the column header in the collapsed state";
37+
})
3238
};
3339
~~~
3440

@@ -80,8 +86,10 @@ To configure the columns appearance, in the **columnShape** object you can speci
8086
~~~
8187
:::
8288

83-
- `fixedHeaders` - (optional) freezes column headers during vertical scroll (*true* by default). Scroll must be enabled in Kanban itself (height must be limited).
84-
- `css` - (optional) a function returns a css class that applies to columns conditionally
89+
- `fixedHeaders` - (optional) freezes column headers during vertical scroll (*true* by default). Scroll must be enabled in Kanban itself (height must be limited)
90+
- `css` - (optional) a function that returns a css class that applies to columns conditionally
91+
- `headerTemplate` - (optional) the HTML template of the column header in the expanded state
92+
- `collapsedTemplate` - (optional) the HTML template of the column header in the collapsed state
8593

8694
### Default config
8795

@@ -114,7 +122,7 @@ const columnShape = {
114122

115123
### Example
116124

117-
~~~jsx {1-30,36}
125+
~~~jsx {1-58,64}
118126
const columnShape = {
119127
menu: {
120128
show: true,
@@ -143,7 +151,35 @@ const columnShape = {
143151
]
144152
},
145153
fixedHeaders: false,
146-
css: (column, cards) => column.id == "inprogress" && cards.length < 5 ? "green" : "red"
154+
css: (column, cards) => column.id == "inprogress" && cards.length < 5 ? "green" : "red",
155+
headerTemplate: template(column => {
156+
return `<div class="wx-collapse-icon" data-action=${"collapse"}>
157+
<i class=${column.column.collapsed ? "wxi-angle-right" : "wxi-angle-left"}></i>
158+
</div>
159+
${
160+
!column.renaming && !column.column.collapsed
161+
? `<div class="wx-label" data-action="rename">
162+
${escapeHTML(column.column.label)}
163+
(${column.columnState.cardsCount})
164+
${column.column.limit ? `(${column.columnState.cardsCount}/${column.columnState.totalLimit})` : ""}
165+
</div>`
166+
: ""
167+
}
168+
${
169+
column.isMenuVisible && !column.readonly && !column.renaming && !column.column.collapsed
170+
? `<div class="wx-menu" data-menu-id={column.id}>
171+
<i class="wxi-dots-h"></i>
172+
</div>`
173+
: ""
174+
}`;
175+
}),
176+
collapsedTemplate: template(column => {
177+
return `<div class="wx-collapsed-label">
178+
<div class="wx-label-text">${escapeHTML(column.column.label)} (${
179+
column.columnState?.cardsCount
180+
})</div>
181+
</div>`;
182+
})
147183
};
148184
149185
new kanban.Kanban("#root", {
@@ -159,6 +195,7 @@ new kanban.Kanban("#root", {
159195
- The ***css*** parameter was added in v1.4
160196
- The ***menu.items[0].label*** parameter was replaced by the ***menu.items[0].text*** parameter in v1.4
161197
- The ***fixedHeaders*** parameter was added in v1.5
198+
- The ***headerTemplate*** and ***collapsedTemplate*** parameters were added in v2.0
162199
163200
**Related articles:** [Configuration](../../../guides/configuration)
164201

0 commit comments

Comments
 (0)