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:
- Buttons - an array of Adaptable Buttons
- 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
Wiring Up Custom Toolbars
Custom Toolbars are provided in a 2-step process:
- The Custom Toolbar is defined in Custom Toolbars in Dashboard Options
- The Custom Toolbar is referenced in Dashboard Initial State
Caution
- This 2-step process is also used if displaying buttons in AdapTable React, AdapTable Angular or AdapTable Vue
- However additional steps are required to display bespoke content - see React, Angular or Vue Components
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
- 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
- The Dashboard API contains functions that enable Custom Toolbars to be accessed and easily updated
- Listen to the Adaptable State Changed Event to be updated when objects change in Adaptable State
Caution
If you have changed a Toolbar progromatically, call refreshDashboard in Dashboard API to update the UI
- 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
- 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
renderproperty is only used when using AdapTable Vanilla - When using a Framework Wrapper, bespoke content is rendered using the
frameworkComponentproperty
Find Out More
- AdapTable React Components explains how to render bespoke Custom Toolbar content in AdapTable React
- AdapTable Angular Components explains how to render bespoke Custom Toolbar content in AdapTable Angular
- AdapTable Vue Components explains how to render bespoke Custom Toolbar content in AdapTable Vue
Deep Dive
Rendering Bespoke Custom Toolbar Content in AdapTable Vanilla
- This demo contains a Tab (entitled Custom Tab) which contins 2 Custom Toolbars with custom rendering:
Hello World- just contains textBespoke 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