Custom Toolbars

Summary

  • Developers are able to provide Custom Toolbars to supplement the System Toolbars shipped by AdapTable
  • These are provided in Dashboard Options and can contain 2 types of content:
    • an array of Adaptable Buttons
    • full bespoke content
  • Once created, Custom Toolbars are treated as full Toolbars and can be placed in any Tab as needed

Custom Toolbars allow developers to provide their own bespoke content inside the AdapTable Dashboard.

Note

  • Custom Toolbars are treated the same as Module Toolbars and can be Pinned or placed in named Tabs
  • AdapTable will take care of ensuring the Toolbar displays / renders when it needs to

2 different sets of content can be provided to a Custom Toolbar:

  1. Buttons - an array of Adaptable Buttons
  2. Bespoke content - for when more than buttons are required

Hint

Each Custom Toolbar contains 2 div elements - one for each method of providing content

customToolbars

Custom Toolbars to show in the Dashboard Header

Wiring Up Custom Toolbars

Custom Toolbars are provided in a 2-step process:

  1. The Custom Toolbar is defined in Custom Toolbars in Dashboard Options
  2. The Custom Toolbar is referenced in Dashboard Initial State

Caution

Developer Guide

Providing a Custom Toolbar in AdapTable Vanilla

Providing AdapTable Buttons

In this option, you simply provide an array of Adaptable Buttons to be displayed in the toolbarButtons property of Custom Toolbar.

Hint

If you require just to display a few buttons in the Custom Toolbar then use this option

Deep Dive

Configuring Custom Toolbar Buttons

Custom Toolbar: Using Buttons
Fork
  • In this example we create a Custom Toolbar - Buttons - which contains 2 AdapTable Buttons (which have been given different styles):
    • Switch Theme - the Text (and click action) changes based on the Current Theme
    • Show Date - shows todays's date as a notification; the label updates every second to display the current time

Expand to see the Adaptable Button definitions

Automating Buttons

A common use case is for the AdapTable Buttons in a Custom Toolbar to be created dynamically.

For instance a user might want to render a button for each Named Query that is available.

Hint

Caution

If you have changed a Toolbar progromatically, call refreshDashboard in Dashboard API to update the UI

Custom Toolbar: Automating Buttons
Fork
  • This demo contains a (pinned) Custom Toolbar displaying a Button for each Named Query in Adaptable State; when clicked, it sets the Grid Filter to that Query
  • We provide 3 Named Queries in Named Query Initial State - JavaScript, Big Stars, Top Frameworks - and the demo renders a button for each (together with a Clear Filter Button)
  • Additional buttons will be created / removed as Queries are manipulated in the UI - achieved by listening to the Adaptable State Changed Event
Try It Out
  • Create a new Named Query and then click the new Button that is dynamically created to run the Expression as a Grid Filter
  • Click one of the Buttons and then edit the associated Named Query in the Expression Editor - note that the the filter automatically updates

Rendering Bespoke Content

If you require to display more than just a few buttons in the Custom Toolbar, there is an alternative which allows you to provide full custom rendering.

This is provided via the render property which is a JavaScript function that you provide and AdapTable will invoke as required.

Caution

  • This render property is only used when using AdapTable Vanilla
  • When using a Framework Wrapper, bespoke content is rendered using the frameworkComponent property

Find Out More

Deep Dive

Rendering Bespoke Custom Toolbar Content in AdapTable Vanilla

Custom Toolbars: Bespoke Content
Fork
  • This demo contains a Tab (entitled Custom Tab) which contins 2 Custom Toolbars with custom rendering:
    • Hello World - just contains text
    • Bespoke Rendering - contins an input

Configuring Custom Toolbars

A Custom Toolbar can be configured to display up to 2 Buttons via the toolbarActions property of the CustomToolbar object (by default neither will display).

  • Close - closes the Custom Toolbar

Hint

If a Custom Toolbar is closed, you need to open the Dashboard page in the Settings Panel to put it back in a Tab

  • Configure - enables the Custom Toolbar to be configured

Note

When clicked it triggers the Custom Toolbar Configured Event allowing custom functionality to be performed