ResourceAssignmentColumn

Column allowing resource manipulation (assignment/unassignment/units changing) on a task. In the column cells, assignments are either shown as badges or avatars. To show avatars, set showAvatars to true. When showing avatars there are two options for how to specify image paths:

  • You may provide a resourceImagePath on your Gantt panel pointing to where resource images are located. Set the resource image filename in the image field of the resource data.
  • And/or you may provide an imageUrl on your record, which then will take precedence when showing images.

If a resource has no name, or its image cannot be loaded, the resource initials are rendered. If the resource has an eventColor specified, it will be used as the background color of the initials.

Resource assignment column
//<code-header>
fiddle.title = 'Resource assignment column';
//</code-header>
const gantt = new Gantt({
    appendTo : targetElement,
    height   : 250,

    subGridConfigs : {
        locked : { flex : 1 },
        normal : { collapsed : true }
    },

    project : {
        startDate : new Date(2020, 0, 1),

        events : [
            {
                id       : 1,
                name     : 'Write docs',
                expanded : true,
                children : [
                    { id : 2, name : 'Proof-read docs', startDate : '2020-01-02', endDate : '2020-01-05', effort : 0 },
                    { id : 3, name : 'Release docs', startDate : '2020-01-09', endDate : '2020-01-10', effort : 0 }
                ]
            }
        ],

        resources : [
            { id : 1, name : 'John Johnson' },
            { id : 2, name : 'Janet Janetson' },
            { id : 3, name : 'Kermit the Frog' },
            { id : 4, name : 'Kermit the Frog Jr.' }
        ],

        assignments : [
            { id : 1, resource : 1, event : 2, units : 50 },
            { id : 2, resource : 3, event : 2 }
        ],

        dependencies : [
            { id : 1, fromEvent : 2, toEvent : 3 }
        ]
    },

    columns : [
        {
            type   : 'resourceassignment',
            width  : 120,
            editor : {
                chipView : {
                    // This template is used when editing the value
                    itemTpl : assignment => assignment.resourceName
                }
            },
            // This template is used by the column
            itemTpl : assignment => assignment.resourceName
        }
    ]
});

Default editor is a AssignmentField.

Customizing displayed elements

If showAvatars is false, column will render resource name and utilization wrapped in a small element called a chip. Content of the chip can be customized. For example, if you don't want to see percent value, or want to display different resource name, you can specify an itemTpl config. Please keep in mind that when you start editing the cell, chip will be rendered by the default editor. If you want chips to be consistent, you need to customize the editor too.

new Gantt({
    columns: [
        {
            type     : 'resourceassignment',
            itemTpl  : assignment => assignment.resourceName,
            editor   : {
                chipView : {
                    itemTpl : assignment => assignment.resourceName
                }
            }
        }
    ]
});

Subscribing to avatar click events

The owning Gantt instance triggers a resourceAssignmentClick` event when a resource avatar or chip is clicked.

new Gantt({
    columns: [
        {
            type         : 'resourceassignment',
            showAvatars : true
        }
    ],
    listeners : {
         resourceAssignmentClick({ taskRecord, resourceRecord, event }) {
             console.log(resourceRecord.name);
         }
     }
});

Configs

86

Common

True to allow drag-drop of resource avatars between rows. Dropping a resource outside the resource assignment cells will unassign the resource.

When true, the names of all overflowing resources are shown in the tooltip. When false, the number of overflowing resources is displayed instead. Only valid for last shown resource, if there are overflowing resources.

True to show a resource avatar for every assignment. Note that you also have to provide a resourceImagePath for where to load images from. And/or you may provide an imageUrl on your record, which then will take precedence when showing images.

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
listenersEvents
maxWidthColumn
textColumn
widthColumn

Other

A config object passed to the avatar Tooltip

const gantt = new Gantt({
    columns : [
         {
             type          : 'resourceassignment',
             showAvatars : true,
             avatarTooltip : {
                 // Allow moving mouse over the tooltip
                 allowOver : true
             }
         }
    ]
});

This function will be called with an object containing the fields below:

A function which receives data about the resource and returns a html string to be displayed in the tooltip.

const gantt = new Gantt({
    columns : [
         {
             type          : 'resourceassignment',
             showAvatars : true,
             avatarTooltipTemplate({ resourceRecord }) {
                 return `<b>${resourceRecord.name}</b>`;
             }
         }
    ]
});

This function will be called with an object containing the fields below:

ParameterTypeDescription
dataObject
data.taskRecordTaskModel

Hovered task

data.resourceRecordResourceModel

Hovered resource

data.assignmentRecordAssignmentModel

Hovered assignment

data.tooltipTooltip

The tooltip instance

data.overflowCountNumber

Number of overflowing resources, only valid for last shown resource

data.overflowAssignmentsAssignmentModel[]

Array of overflowing assignments, only valid for last shown resource

Returns: DomConfig | String | null
formulaColumn
pinnedColumn
readOnlyColumn

Rendering

A function which produces the content to put in the resource assignment cell. May be overridden in subclasses, or injected into the column to customize the Chip content.

Defaults to returning ${assignment.resourceName} ${assignment.units}%

ParameterTypeDescription
assignmentAssignmentModel

The assignment

indexNumber

The index - zero based.

Returns: DomConfig | String | null
cellClsColumn
clsColumn
iconColumn
rendererColumn
tooltipColumn

Accessibility

ariaLabelColumn

Export

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

Layout

alignColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Menu

Merge cells

mergeableColumn

Misc

localeClassLocalizable
localizableLocalizable
tagsColumn
treeColumn

Summary

sumColumn
summariesColumn

Properties

156

Common

True to allow drag-drop of resource avatars between rows. Dropping a resource outside the resource assignment cells will unassign the resource.

When true, the names of all overflowing resources are shown in the tooltip. When false, the number of overflowing resources is displayed instead. Only valid for last shown resource, if there are overflowing resources.

True to show a resource avatar for every assignment. Note that you also have to provide a resourceImagePath for where to load images from. And/or you may provide an imageUrl on your record, which then will take precedence when showing images.

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
maxWidthColumn
textColumn
widthColumn

Class hierarchy

isResourceAssignmentColumn: Boolean= truereadonly
Identifies an object as an instance of ResourceAssignmentColumn class, or subclass thereof.
isResourceAssignmentColumn: Boolean= truereadonlystatic
Identifies an object as an instance of ResourceAssignmentColumn class, or subclass thereof.
isColumnColumn
isEventsEvents
isLocalizableLocalizable
isModelModel
isModelLinkModelLink
isModelStmModelStm
isTreeNodeTreeNode

Other

A config object passed to the avatar Tooltip

const gantt = new Gantt({
    columns : [
         {
             type          : 'resourceassignment',
             showAvatars : true,
             avatarTooltip : {
                 // Allow moving mouse over the tooltip
                 allowOver : true
             }
         }
    ]
});

This function will be called with an object containing the fields below:

A function which receives data about the resource and returns a html string to be displayed in the tooltip.

const gantt = new Gantt({
    columns : [
         {
             type          : 'resourceassignment',
             showAvatars : true,
             avatarTooltipTemplate({ resourceRecord }) {
                 return `<b>${resourceRecord.name}</b>`;
             }
         }
    ]
});

This function will be called with an object containing the fields below:

ParameterTypeDescription
dataObject
data.taskRecordTaskModel

Hovered task

data.resourceRecordResourceModel

Hovered resource

data.assignmentRecordAssignmentModel

Hovered assignment

data.tooltipTooltip

The tooltip instance

data.overflowCountNumber

Number of overflowing resources, only valid for last shown resource

data.overflowAssignmentsAssignmentModel[]

Array of overflowing assignments, only valid for last shown resource

Returns: DomConfig | String | null
$namestaticModel
defaultsColumn
elementColumn
formulaColumn
gridColumn
pinnedColumn
readOnlyColumn
relationsstaticModel
subGridColumn
typestaticColumn
visibleColumn

Rendering

A function which produces the content to put in the resource assignment cell. May be overridden in subclasses, or injected into the column to customize the Chip content.

Defaults to returning ${assignment.resourceName} ${assignment.units}%

ParameterTypeDescription
assignmentAssignmentModel

The assignment

indexNumber

The index - zero based.

Returns: DomConfig | String | null
cellClsColumn
clsColumn
iconColumn
rendererColumn
tooltipColumn

Accessibility

ariaLabelColumn

Editing

copyOfModel
isValidModel

Export

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

JSON

jsonModel

Layout

alignColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Menu

Merge cells

mergeableColumn

Misc

localeHelperLocalizable
localeManagerLocalizable
stmModelStm
tagsColumn
treeColumn

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Summary

sumColumn
summariesColumn

Functions

77

Configuration

applyDefaultsstaticBase

Editing

copyModel
getDataModel
removeModel
setModel

Events

Fields

addFieldstaticModel
getModel
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Misc

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase
optionalLstaticLocalizable

Other

hideColumn
LstaticLocalizable
onEvents
relayAllEvents
showColumn
toggleColumn
triggerEvents
unEvents

Parent & children

appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Events

5

Event handlers

5

Typedefs

2

CSS variables

1
NameDescription
--b-resource-assignment-column-avatar-backgroundBackground for avatars in the resource assignment column