Skip to content

Commit 6b9c1cc

Browse files
Merge pull request #100 from DHTMLX/sp-SVAR-2717
[update] document columnShape header template props
2 parents a128322 + d65aca1 commit 6b9c1cc

1 file changed

Lines changed: 34 additions & 14 deletions

File tree

docs/api/config/js_kanban_columnshape_config.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ columnShape?: {
3030
},
3131
fixedHeaders?: boolean,
3232
css?: (column, cards) => string,
33-
headerTemplate?: template(column => {
33+
headerTemplate?: template(props => {
3434
return "The HTML template of the column header in the expanded state";
3535
}),
36-
collapsedTemplate?: template(column => {
36+
collapsedTemplate?: template(props => {
3737
return "The HTML template of the column header in the collapsed state";
3838
}),
3939
confirmDeletion?: boolean
@@ -94,8 +94,28 @@ To configure the columns appearance, in the **columnShape** object you can speci
9494

9595
- `fixedHeaders` - (optional) freezes column headers during vertical scroll (*true* by default). Scroll must be enabled in Kanban itself (height must be limited)
9696
- `css` - (optional) a function that returns a css class that applies to columns conditionally
97-
- `headerTemplate` - (optional) the HTML template of the column header in the expanded state
98-
- `collapsedTemplate` - (optional) the HTML template of the column header in the collapsed state
97+
- `headerTemplate` - (optional) the HTML template of the column header in the expanded state. The function receives a `props` object with the following properties:
98+
- `column` - (object) the column data (see [`columns`](api/config/js_kanban_columns_config.md) for the structure)
99+
- `columnState` - (object) the current state of the column. It always includes:
100+
- ***columnId*** - (string | number) the ID of the column
101+
- ***column*** - (object) the column data (same as `props.column`)
102+
- ***cardsCount*** - (number) the number of cards in the column
103+
- ***noFreeSpace*** - (boolean) ***true*** when the column cannot accept more cards
104+
105+
When the [`columns[i].limit`](api/config/js_kanban_columns_config.md) parameter is enabled, it also includes:
106+
- ***totalLimit*** - (number) the configured cards limit
107+
- ***isOverLimit*** - (boolean) ***true*** when the number of cards exceeds the limit
108+
109+
When the column belongs to a swimlane (row), it also includes:
110+
- ***rowId*** - (string | number) the ID of the row
111+
- ***row*** - (object) the row data (see [`rows`](api/config/js_kanban_rows_config.md) for the structure)
112+
- ***height*** - (number) the height of the area
113+
- `isMenuVisible` - (boolean) ***true*** when the menu should be shown for this column header
114+
- `renaming` - (boolean) ***true*** when the input for editing the column name is active
115+
- `readonly` - (boolean) ***true*** when column editing is disabled (equivalent of `!readonly.edit`, see the [`readonly`](api/config/js_kanban_readonly_config.md) property)
116+
- `collapsedTemplate` - (optional) the HTML template of the column header in the collapsed state. The function receives a `props` object with the following properties:
117+
- `column` - (object) the column data (see [`columns`](api/config/js_kanban_columns_config.md))
118+
- `columnState` - (object) the current state of the column. The shape is the same as `columnState` in the [`headerTemplate`](#parameters) parameter above
99119
- `confirmDeletion` - (optional) shows/hides the **confirmation dialog** that allows users to confirm or decline the column deletion
100120

101121
### Default config
@@ -160,30 +180,30 @@ const columnShape = {
160180
},
161181
fixedHeaders: false,
162182
css: (column, cards) => column.id == "inprogress" && cards.length < 5 ? "green" : "red",
163-
headerTemplate: template(column => {
183+
headerTemplate: template(props => {
164184
return `<div class="wx-collapse-icon" data-action=${"collapse"}>
165-
<i class=${column.column.collapsed ? "wxi-angle-right" : "wxi-angle-left"}></i>
185+
<i class=${props.column.collapsed ? "wxi-angle-right" : "wxi-angle-left"}></i>
166186
</div>
167187
${
168-
!column.column.collapsed
188+
!props.column.collapsed
169189
? `<div class="wx-label" data-action="rename">
170-
${escapeHTML(column.column.label)}
171-
(${column.columnState.cardsCount})
190+
${escapeHTML(props.column.label)}
191+
(${props.columnState.cardsCount})
172192
</div>`
173193
: ""
174194
}
175195
${
176-
!column.column.collapsed
177-
? `<div class="wx-menu" data-menu-id=${column.id}>
196+
!props.column.collapsed
197+
? `<div class="wx-menu" data-menu-id=${props.column.id}>
178198
<i class="wxi-dots-h"></i>
179199
</div>`
180200
: ""
181201
}`;
182202
}),
183-
collapsedTemplate: template(column => {
203+
collapsedTemplate: template(props => {
184204
return `<div class="wx-collapsed-label">
185-
<div class="wx-label-text">${escapeHTML(column.column.label)} (${
186-
column.columnState?.cardsCount
205+
<div class="wx-label-text">${escapeHTML(props.column.label)} (${
206+
props.columnState?.cardsCount
187207
})</div>
188208
</div>`;
189209
}),

0 commit comments

Comments
 (0)