ActionColumn

A column that displays actions as clickable icons in the cell.

Action column
//<code-header>
fiddle.title = 'Action column';
//</code-header>
// tree with ActionColumn
const tree = new TreeGrid({
    appendTo   : targetElement,
    autoHeight : true,
    columns    : [
        { type : 'tree', field : 'name', text : 'Name', flex : 1 },
        { type : 'number', field : 'born', text : 'Born', flex : 1 },
        { type : 'number', field : 'salary', text : 'Salary' },
        {
            type    : 'action',
            text    : 'Actions',
            width   : 100,
            actions : [{
                cls     : 'fa fa-minus',
                tooltip : 'Decrease salary',
                visible : ({ record }) => !Boolean(record.children && record.children.length),
                onClick : ({ record }) => {
                    if (record.salary > 1000) {
                        record.salary = record.salary - 1000;
                    }
                }
            }, {
                cls     : 'fa fa-plus',
                tooltip : 'Increase salary',
                visible : ({ record }) => !Boolean(record.children && record.children.length),
                onClick : ({ record }) => record.salary = record.salary + 1000
            },
            {
                cls     : 'fa fa-trash',
                tooltip : 'Remove row',
                onClick : ({ record }) => record.remove()
            }]
        }
    ],
    data : [
        {
            id       : 1,
            name     : 'ABBA',
            iconCls  : 'b-icon fa-users',
            born     : null,
            salary   : null,
            expanded : true,
            children : [
                { id : 11, name : 'Anni-Frid', born : 1945, salary : 50000, iconCls : 'b-icon fa-user' },
                { id : 12, name : 'Bjorn', born : 1945, salary : 140000, iconCls : 'b-icon fa-user' },
                { id : 13, name : 'Benny', born : 1946, salary : 400000, iconCls : 'b-icon fa-user' },
                { id : 14, name : 'Agnetha', born : 1950, salary : 40000, iconCls : 'b-icon fa-user' }
            ]
        },
        {
            id       : 2,
            name     : 'Roxette',
            iconCls  : 'b-icon fa-users',
            born     : null,
            salary   : null,
            children : [
                { id : 21, name : 'Per', born : 1959, salary : 88000, iconCls : 'b-icon fa-user' },
                { id : 22, name : 'Marie', born : 1958, salary : 70000, iconCls : 'b-icon fa-user' }
            ]
        }
    ]
});

new TreeGrid({
    appendTo : document.body,
    columns  : [{
        type    : 'action',
        text    : 'Increase amount',
        actions : [{
            cls      : 'fa fa-plus',
            renderer : ({ action, record }) => `<i class="b-action-item ${action.cls} b-${record.enabled ? "green" : "red"}-class"></i>`,
            visible  : ({ record }) => record.canAdd,
            tooltip  : ({ record }) => `<p class="b-nicer-than-default">Add to ${record.name}</p>`,
            onClick  : ({ record }) => console.log(`Adding ${record.name}`)
        }, {
            cls     : 'fa fa-pencil',
            tooltip : 'Edit note',
            onClick : ({ record }) => console.log(`Editing ${record.name}`)
        }]
    }]
});

Actions may be placed in Group headers, by setting action.showForGroup to true. Those actions will not be shown on normal rows.

Accessibility

If ariaLabel is omitted, adding a tooltip to an action will automatically set this as the aria-label for the button element. Use ariaHasPopup to indicate that the action triggers a popup, helping assistive technology users understand the interaction behavior.

Configs

82

Common

An array of action config objects, see ActionConfig for details.

new Grid({
    columns  : [{
        type    : 'action',
        text    : 'Actions',
        actions : [{
            cls      : 'fa fa-plus',
            visible  : ({ record }) => record.canAdd,
            onClick  : ({ record }) => console.log(`Adding ${record.name}`)
        }, {
            cls     : 'fa fa-pencil',
            tooltip : 'Edit note',
            onClick : ({ record }) => console.log(`Editing ${record.name}`)
        }]
    }]
});

Set to true to disable actions in this column if the grid is readOnly

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
listenersEvents
maxWidthColumn
textColumn
widthColumn

Layout

minWidth: Number | String= 30Also a property

Column minimal width. If value is Number then minimal width is in pixels.

alignColumn
hiddenColumn
lockedColumn
regionColumn

Accessibility

ariaLabelColumn

Export

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

Menu

Merge cells

mergeableColumn

Misc

localeClassLocalizable
localizableLocalizable
tagsColumn
treeColumn

Other

formulaColumn
pinnedColumn
readOnlyColumn

Rendering

cellClsColumn
clsColumn
iconColumn
rendererColumn
tooltipColumn

Summary

sumColumn
summariesColumn

Properties

152

Common

An array of action config objects, see ActionConfig for details.

new Grid({
    columns  : [{
        type    : 'action',
        text    : 'Actions',
        actions : [{
            cls      : 'fa fa-plus',
            visible  : ({ record }) => record.canAdd,
            onClick  : ({ record }) => console.log(`Adding ${record.name}`)
        }, {
            cls     : 'fa fa-pencil',
            tooltip : 'Edit note',
            onClick : ({ record }) => console.log(`Editing ${record.name}`)
        }]
    }]
});

Set to true to disable actions in this column if the grid is readOnly

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
maxWidthColumn
textColumn
widthColumn

Class hierarchy

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

Layout

minWidth: Number | String= 30Also a config

Column minimal width. If value is Number then minimal width is in pixels.

alignColumn
hiddenColumn
lockedColumn
regionColumn

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

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Menu

Merge cells

mergeableColumn

Misc

localeHelperLocalizable
localeManagerLocalizable
stmModelStm
tagsColumn
treeColumn

Other

$namestaticModel
defaultsColumn
elementColumn
formulaColumn
gridColumn
pinnedColumn
readOnlyColumn
relationsstaticModel
subGridColumn
typestaticColumn
visibleColumn

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Rendering

cellClsColumn
clsColumn
iconColumn
rendererColumn
tooltipColumn

Summary

sumColumn
summariesColumn

Functions

76

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

3

Config object for an action in an ActionColumn.

ParameterTypeDescription
clsString

CSS Class for action icon

ariaLabelString

A text to use for the action element's aria-label value. If not provided, the action's tooltip will be used as the aria-label (if present).

ariaHasPopuptrue | false | menu | listbox | tree | grid | dialog | Boolean

A value to use for the action element's aria-haspopup attribute. Set to indicate that the action triggers a popup. This helps assistive technologies inform users that activating the action will display a popup element.

tooltipfunction | String | TooltipConfig

Tooltip text, or a config object which can reconfigure the shared tooltip by setting boolean, numeric and string config values, or a function to return the tooltip text, passed the row's record

tooltip.recordModel

The record

visiblefunction | Boolean

Boolean to define the action icon visibility or a callback function, passed the row's record, to change it dynamically

onClickfunction

Callback to handle click action item event

onClick.recordModel

The row record

onClick.targetHTMLElement

The clicked action element

onClick.actionActionConfig

The clicked action config

onClick.gridGridBase

The Grid instance

onClick.columnActionColumn

The ActionColumn instance

showForGroupBoolean

Set to true to have action icon visible in group headers only when using the group feature

rendererfunction | String

A render function, or the name of a function in the Grid's ownership tree used to define the action element. Passed the row's record, expected to return an HTML string or a DOM config object.

Note: when specified, the cls action config is ignored. Make sure you add an action icon manually, for example:

{
     type    : 'action',
     text    : 'Increase amount',
     actions : [{
         cls      : 'fa fa-plus', // this line will be ignored
         renderer : ({ record }) => '<i class="b-action-item fa fa-plus"></i> ' + record.name,
         onClick  : ({ record }) => {}
     }]
}

or

{
     type    : 'action',
     text    : 'Increase amount',
     actions : [{
         cls      : 'fa fa-plus', // this line will be ignored
         renderer : 'up.renderAction' // Defined on the Grid
         onClick  : ({ record }) => {}
     }]
}
renderer.recordModel

The record

CSS variables

5
NameDescription
--b-action-column-button-sizeButton size (applied as font-size)
--b-action-column-colorButton color
--b-action-column-row-hover-colorButton color when row is hovered or selected
Hovered
--b-action-column-hover-colorButton color when hovered
Readonly
--b-action-column-readonly-colorButton color when readonly