Action Column Buttons
Summary
- A
buttonControl is a clickable button in an Action Column cell - It is the same Adaptable Button used in the Dashboard, Toolbars, Tool Panel and Forms
onClickreceivesActionColumnContext- Optional
confirmand asyncbusyLabelcover prompts and pending state
The button Control is the most common Action Column Control.
Note
Up to Version 24 it was the only control available in an Action Column
It is the same Adaptable Button that appears throughout AdapTable — Dashboard buttons, Custom Toolbar buttons, Tool Panel buttons, and Form footer buttons.
The most important property is the onClick function which defines what happens when the button is clicked.
Hint
onClickreceivesActionColumnContext- If the function returns a
Promise, the button shows a pending state (optionalbusyLabel) until it resolves
The other properties are identical to a normal button: label, icon, iconPosition etc.
As with the AdapTable Button they can return or a static value or function that returns a value based on the row.
There is also a style property which is the same as the button's buttonStyle property (with tone & variant).
Note
- The prop is
stylebecause lives on sharedBaseControlused by all Action Column Controls, not only buttons - The type is still
ButtonStyle; handlers receive only theActionColumnContext(no separate button argument)
There is an optional confirm which shows a prompt before the handler runs.
Developer Guide
Defining a Button Control
actionColumnOptions: {
actionColumns: [
{
columnId: 'update_stars',
friendlyName: 'Update Stars',
controls: [
{
type: 'button',
label: (context) =>
context.data.language === 'JavaScript'
? 'Add Star'
: 'Remove Star',
style: (context) =>
context.data.language === 'JavaScript'
? {variant: 'raised', tone: 'accent'}
: {variant: 'raised', tone: 'success'},
onClick: (context) => {
const increment =
context.data.language === 'JavaScript' ? 1 : -1;
context.adaptableApi.gridApi.setCellValue({
columnId: 'github_stars',
newValue: context.data.github_stars + increment,
primaryKeyValue: context.primaryKeyValue,
rowNode: context.rowNode,
});
},
hidden: (context) =>
context.data.name === 'stencil' ||
context.data.name === 'polymer',
disabled: (context) =>
context.data.github_watchers < 200,
},
],
},
],
},Put the Column in actionColumnOptions.actionColumns.
Supply columnId and an optional friendlyName (used as the header caption).
Each item in controls needs a type. For a button this is 'button'.
label and style can be functions of the row — here they change when Language is JavaScript.
onClick receives the Action Column context and updates the row.
hidden and disabled are also functions of the context.
Update Starsincrements or decrementsGithub Starslabelandstylechange whenLanguageis JavaScripthiddenwhen theNameis stencil or polymerdisabledif fewer than 200Github Watchers
TSis an icon-only button that opens the TypeScript site, hidden unlessLanguageis TypeScript
Multiple Buttons
There is no limit on the number of Buttons (or other Controls) in one Column.
Update IssueshasUpandDownbuttons that changeIssue ChangeManage Rowis pinned right and usescreate/deleteCommands instead