ColumnDrag
This feature allows users to drag columns on the TaskBoard to change the column order. Drag is initiated upon mouse down in the column header. Try it out below!
//<code-header>
fiddle.title = 'Column drag';
//</code-header>
const taskBoard = new TaskBoard({
appendTo : targetElement,
features : {
columnDrag : true,
columnToolbars : false
},
columns : [
'todo',
{ id : 'doing', text : 'Drag me' },
'done'
],
columnField : 'status',
project : {
tasks : [
{ id : 1, name : 'Easter campaign', status : 'doing', prio : 'high' },
{ id : 2, name : 'Follow up', status : 'done', prio : 'low' },
{ id : 3, name : 'Adjust ads', status : 'doing', prio : 'low' },
{ id : 4, name : 'Spring campaign', status : 'todo', prio : 'low' },
{ id : 5, name : 'Survey', status : 'todo', prio : 'low' }
]
}
});Works just as well when using swimlanes:
//<code-header>
fiddle.title = 'Column drag swimlanes';
//</code-header>
const taskBoard = new TaskBoard({
appendTo : targetElement,
features : {
columnDrag : true,
columnToolbars : false
},
// Swimlanes to display
swimlanes : [
'high',
'low'
],
swimlaneField : 'prio',
columns : [
'todo',
'doing',
'done'
],
columnField : 'status',
project : {
tasks : [
{ id : 1, name : 'Easter campaign', status : 'doing', prio : 'high' },
{ id : 2, name : 'Follow up', status : 'done', prio : 'low' },
{ id : 3, name : 'Adjust ads', status : 'doing', prio : 'low' },
{ id : 4, name : 'Spring campaign', status : 'todo', prio : 'low' },
{ id : 5, name : 'Survey', status : 'todo', prio : 'low' }
]
}
});Drag events
The different stages of a drag operation trigger different events, in order of appearance:
| Event | Description |
|---|---|
| beforeColumnDrag | Preventable event fired before a drag starts |
| columnDragStart | Fired when dragging starts |
| columnDrag | Fired when movement during a drag will lead to changes |
| beforeColumnDrop | Preventable event fired before finalizing a valid drop. Allows async listeners |
| columnDrop | Fired after finalizing a valid drop |
| columnDragAbort | Fired when a drag is aborted (ESC, drop out of bounds or by a listener) |
| columnDragEnd | Fired when a started drag ends, no matter the outcome |
This feature is disabled by default.
Configs
9
Configs
9Misc
Other
Properties
16
Properties
16Common
Class hierarchy
Other
Functions
28
Functions
28Configuration
Events
Misc
Other
Events
12
Events
12Fires on the owning TaskBoard before column dragging starts. Return false to prevent the action
// Adding a listener using the "on" method
columnDrag.on('beforeColumnDrag', ({ source, columnRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column to be dragged |
Fires on the owning TaskBoard when dropping a column, before the operation completes. Handles async
listeners, returning false from one will abort the operation
const taskBoard = new TaskBoard({
listeners : {
async beforeColumnDrop({ columnRecord, beforeColumn }) {
// Show confirmation dialog
const result = await MessageDialog.confirm({
title : 'Verify drop',
message : `Please confirm moving ${columnRecord.text} before ${beforeColumn.text}?`
});
// Returning false will abort the drop (if user pressed Cancel)
return result === MessageDialog.okButton;
}
}
});
// Adding a listener using the "on" method
columnDrag.on('beforeColumnDrop', ({ source, columnRecord, beforeColumn }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dropped column |
beforeColumn | ColumnModel | Dropped before this column |
Fires on the owning TaskBoard when a column is dragged, if the drag leads to a change compared to the last columnDrag event.
Returning false from a listener will flag the drag as invalid (by default turning the drop
indicator red)
const taskBoard = new TaskBoard({
listeners : {
// Do not allow moving beyond last column
columnDrag({ columnRecord, beforeColumn }) {
return beforeColumn === null;
}
}
});
// Adding a listener using the "on" method
columnDrag.on('columnDrag', ({ source, columnRecord, beforeColumn }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column being dragged |
beforeColumn | ColumnModel | Insert before this column on drop, |
Fires on the owning TaskBoard when a drag operation is aborted (invalid drop or aborted using ESC)
// Adding a listener using the "on" method
columnDrag.on('columnDragAbort', ({ source, columnRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dragged column |
Fires on the owning TaskBoard when a previously started drag operation ends, no matter the outcome of it (whether valid, invalid or aborted)
// Adding a listener using the "on" method
columnDrag.on('columnDragEnd', ({ source, columnRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Affected column |
Fires on the owning TaskBoard when column dragging starts
// Adding a listener using the "on" method
columnDrag.on('columnDragStart', ({ source, columnRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column to be dragged |
Fires on the owning TaskBoard when a column is successfully dropped (after the drop transition has finished)
// Adding a listener using the "on" method
columnDrag.on('columnDrop', ({ source, columnRecord, beforeColumn, targetSwimlane }) => {
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dropped column |
beforeColumn | ColumnModel | Dropped before this column ( |
targetSwimlane | SwimlaneModel | Dropped in this swimlane (if used) |
Event handlers
12
Event handlers
12Called on the owning TaskBoard before column dragging starts. Return false to prevent the action
new ColumnDrag({
onBeforeColumnDrag({ source, columnRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column to be dragged |
Called on the owning TaskBoard when dropping a column, before the operation completes. Handles async
listeners, returning false from one will abort the operation
const taskBoard = new TaskBoard({
listeners : {
async beforeColumnDrop({ columnRecord, beforeColumn }) {
// Show confirmation dialog
const result = await MessageDialog.confirm({
title : 'Verify drop',
message : `Please confirm moving ${columnRecord.text} before ${beforeColumn.text}?`
});
// Returning false will abort the drop (if user pressed Cancel)
return result === MessageDialog.okButton;
}
}
});
new ColumnDrag({
onBeforeColumnDrop({ source, columnRecord, beforeColumn }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dropped column |
beforeColumn | ColumnModel | Dropped before this column |
Called on the owning TaskBoard when a column is dragged, if the drag leads to a change compared to the last columnDrag event.
Returning false from a listener will flag the drag as invalid (by default turning the drop
indicator red)
const taskBoard = new TaskBoard({
listeners : {
// Do not allow moving beyond last column
columnDrag({ columnRecord, beforeColumn }) {
return beforeColumn === null;
}
}
});
new ColumnDrag({
onColumnDrag({ source, columnRecord, beforeColumn }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column being dragged |
beforeColumn | ColumnModel | Insert before this column on drop, |
Called on the owning TaskBoard when a drag operation is aborted (invalid drop or aborted using ESC)
new ColumnDrag({
onColumnDragAbort({ source, columnRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dragged column |
Called on the owning TaskBoard when a previously started drag operation ends, no matter the outcome of it (whether valid, invalid or aborted)
new ColumnDrag({
onColumnDragEnd({ source, columnRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Affected column |
Called on the owning TaskBoard when column dragging starts
new ColumnDrag({
onColumnDragStart({ source, columnRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Column to be dragged |
Called on the owning TaskBoard when a column is successfully dropped (after the drop transition has finished)
new ColumnDrag({
onColumnDrop({ source, columnRecord, beforeColumn, targetSwimlane }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | TaskBoard | Owning TaskBoard |
columnRecord | ColumnModel | Dropped column |
beforeColumn | ColumnModel | Dropped before this column ( |
targetSwimlane | SwimlaneModel | Dropped in this swimlane (if used) |
Typedefs
1
Typedefs
1CSS variables
6
CSS variables
6| Name | Description |
|---|---|
--b-task-board-column-drag-background | Drag proxy background |
--b-task-board-column-drag-box-shadow | Drag proxy box shadow |
--b-task-board-column-drag-drop-background | Drop indicator background |
--b-task-board-column-drag-drop-border | Drop indicator border |
--b-task-board-column-drag-invalid-background | Invalid drop indicator background |
--b-task-board-column-drag-invalid-color | Invalid drop indicator border color |