Adaptable Buttons

Summary

  • Adaptable Buttons are widely used in AdapTable and are highly configurable and flexible
  • Buttons can appear standalone in AdapTable (e.g in the Dashboard, ToolPanel or Action Columns)
  • Buttons can also appear in an Adaptable Form (e.g. when using Alerts, Custom Export Destinations or DataSets)

An AdapTable Button is designed to be extremely configurable and styleable.

It contains many optional properties which can be provided as required.

The properties that use a function always receive the same 2 parameters when invoked (and returns an appropriate value):

Button Properties

The Adaptable Button has a number of properties and is defined as follows:

PropertyDescription
buttonStyleStyle for Button - can be object or function that provides a ButtonStyle object
disabledFunction that disables / enables the button based on its evaluation result
hiddenFunction which sets whether Button is hidden
iconIcon for Button - can be object or function that provides a AdaptableIcon object
labelLabel for Button - can be string or function that provides string
onClickFunction to invoke when button is clicked
tooltipTooltip for Button - can be string or function that provides string

onClick

onClick is the function which is called when the Button is clicked and returns void:

onClick?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => void;

Note

Although not mandatory, this function should nearly always be provided in practice

label

The text to show as the Button's caption.

The property can return either a string or a function which returns a string:

label?: string |
  (((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string);

buttonStyle

Provides the Button Style for the Button.

The property can return either a ButtonStyle object or a function which returns a ButtonStyle:

buttonStyle?: ButtonStyle |
  ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => ButtonStyle);

toolTip

The text to use as the Button's Tooltip.

The property can return either a string or a function which returns a string:

toolTip?: string |
  ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => string);

hidden

Function that returns whether or not the Button will display.

Caution

If this property is not provided the Button will always be displayed

The function is invoked when the Button is about to be rendered - allowing you to decide whether it should display - and returns a boolean:

hidden?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => boolean;

disabled

Function that disables / enables the button based on its evaluation result:

disabled?: (button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => boolean;

icon

The property can return either an AdaptableIcon or a function which returns an AdaptableIcon:

icon?: AdaptableIcon | ((button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE) => AdaptableIcon);

Find Out More

See the Guide to Adaptable Icons for details on how to provide custom icons

Button Style

AdapTable provides a ButtonStyle object which defines how a Button will be visually rendered.

The object has 3 properties:

PropertyDescriptionDefault
classNameCSS Classname to use for the Button
toneButton's Tone - values: 'success', 'error', 'neutral', 'none', 'warning', 'info', 'accent''neutral'
variantHow Button appears - values: 'text', 'outlined', 'raised''outlined'
Deep Dive

Understanding Button Style

Button Contexts

All the functions that the Button can receive, include a Context parameter.

Each implementation of the Adaptable Button in AdapTable will be provided with its own, bespoke, context property that contains information relevant to that particular use case.

Note

In addition the button argument is of generic type of the same Context

button: AdaptableButton<CONTEXT_TYPE>, context: CONTEXT_TYPE

There are 8 Context Types - for 8 different use cases where Adaptable Buttons are provided:

ClassModuleWhen UsedBase Class
ActionColumnContextAction ColumnIn the generated buttonsBaseContext
AlertFormContextAlertWhen a Notification is displayedFormContext
ExportFormContextExportIn Custom Destination FormsFormContext
DashboardButtonContextDashboardIn Dashboard ButtonsBaseContext
CustomToolbarButtonContextCustom ToolbarButtons in Custom ToolbarsBaseContext
ToolPanelButtonContextToolPanelIn ToolPanel ButtonsBaseContext
CustomToolPanelButtonContextCustom ToolPanelButtons in Custom ToolPanelsBaseContext
DataSetFormContextDataSetWhen a DataSet displays a FormFormContext
Deep Dive

Understanding Button Context