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!

Column drag
//<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:

Column drag 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

Common

disabledInstancePlugin
listenersEvents

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Other

Properties

16

Common

disabledInstancePlugin

Class hierarchy

isColumnDrag: Boolean= truereadonly
Identifies an object as an instance of ColumnDrag class, or subclass thereof.
isColumnDrag: Boolean= truereadonlystatic
Identifies an object as an instance of ColumnDrag class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable
isTaskBoardFeatureTaskBoardFeature

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

Functions

28

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

12

Fires 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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Dropped column

beforeColumnColumnModel

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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Column being dragged

beforeColumnColumnModel

Insert before this column on drop, null if last

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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Affected column

Fires on the owning TaskBoard when column dragging starts

// Adding a listener using the "on" method
columnDrag.on('columnDragStart', ({ source, columnRecord }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) => {

});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Dropped column

beforeColumnColumnModel

Dropped before this column (null if last)

targetSwimlaneSwimlaneModel

Dropped in this swimlane (if used)

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

12

Called on the owning TaskBoard before column dragging starts. Return false to prevent the action

new ColumnDrag({
    onBeforeColumnDrag({ source, columnRecord }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Dropped column

beforeColumnColumnModel

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 }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Column being dragged

beforeColumnColumnModel

Insert before this column on drop, null if last

Called on the owning TaskBoard when a drag operation is aborted (invalid drop or aborted using ESC)

new ColumnDrag({
    onColumnDragAbort({ source, columnRecord }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Affected column

Called on the owning TaskBoard when column dragging starts

new ColumnDrag({
    onColumnDragStart({ source, columnRecord }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

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 }) {

    }
});
ParameterTypeDescription
sourceTaskBoard

Owning TaskBoard

columnRecordColumnModel

Dropped column

beforeColumnColumnModel

Dropped before this column (null if last)

targetSwimlaneSwimlaneModel

Dropped in this swimlane (if used)

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1

CSS variables

6
NameDescription
--b-task-board-column-drag-backgroundDrag proxy background
--b-task-board-column-drag-box-shadowDrag proxy box shadow
--b-task-board-column-drag-drop-backgroundDrop indicator background
--b-task-board-column-drag-drop-borderDrop indicator border
--b-task-board-column-drag-invalid-backgroundInvalid drop indicator background
--b-task-board-column-drag-invalid-colorInvalid drop indicator border color