Custom Tool Panels

Summary

  • Custom Tool Panels are Tool Panels provided by Developers
  • They are provided in Tool Panel Options
  • They are hosted in the Adaptable Tool Panel Component

Developers are able to provide custom ToolPanels containing bespoke elements.

They are rendered inside the Adaptable ToolPanel Component alongside the Module ToolPanels.

Note

Once defined, Custom ToolPanels can be configured and used in the same way as Module ToolPanels

Wiring Up Custom Tool Panels

Custom Tool Panels are provided in a 2-step process:

  1. The Custom Tool Panel is defined in customToolPanels in Tool Panel Options
  2. The Custom Tool Panel is referenced in Tool Panel Initial State
Developer Guide

Wiring up a Custom Tool Panel

These are the 2 steps required to provide a Custom Tool Panel in AdapTable.

const adaptableOptions: AdaptableOptions = {
  toolPanelOptions: {
    customToolPanels: [
      {
        name: 'buttonCustomToolPanel',
        title: 'Quick Actions',
        buttons: [
          // Adaptable Buttons here
        ],
      },
      {
        name: 'bespokeContentCustomToolPanel',
        title: 'Custom Content',
        frameworkComponent: () => {
          // bespoke content; use render if AdapTable Vanilla
        },
      },
    ],
  },
};
1
Create the Tool Panel in Tool Panel Options

Create the Custom Tool Panel in customToolPanels in Tool Panel Options.

  • Add name — how the Tool Panel is internally referenced in AdapTable
  • Optionally add title — the label shown in the Tool Panel header
  • Add the content (either AdapTable Buttons or bespoke rendering)
initialState: {
  ToolPanel: {
    ToolPanels: [
      {
        Name: 'buttonCustomToolPanel',
        VisibilityMode: 'expanded',
      },
      {
        Name: 'bespokeContentCustomToolPanel',
        VisibilityMode: 'collapsed',
      },
    ];
  }
}
2
Add Tool Panel and set visibility in Initial Adaptable State

Reference the Custom Tool Panel in Tool Panel Initial State.

Use the name supplied in Tool Panel Options.

Optionally configure the Tool Panel to display as expanded or collapsed.

Custom Tool Panel Contents

Custom Tool Panels can contain 2 different sets of content:

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

Anatomy of a Custom ToolPanel

Providing AdapTable Buttons

Provide an array of Adaptable Buttons on the buttons property of CustomToolPanel.

This workflow is framework-agnostic — the same buttons configuration works for AdapTable Vanilla, React, Angular, and Vue.

Hint

If you only need a few actions in the Tool Panel, prefer buttons over bespoke render / frameworkComponent content

Developer Guide

Providing Custom Tool Panel Buttons

Deep Dive

Configuring Custom Tool Panel Buttons

Custom Tool Panel: Using Buttons
Fork
  • This example defines one Custom Tool Panel — Quick Actions — containing three AdapTable Buttons:
    • Switch Theme — toggles light / dark theme
    • Open Named Queries — opens the Named Query settings panel
    • Show Date — displays today's date in an alert
  • The AdapTable Tool Panel opens on load so the Custom Tool Panel is visible

Providing Bespoke Content

When Adaptable Buttons are not enough, you can provide bespoke HTML in a Custom Tool Panel.

This is done using the render property — a function that returns an HTML string (or null).

render?: (context: CustomRenderContext) => string | null;

The function receives CustomRenderContext defined as follows:

PropertyTypeDescription
elementHTMLDivElementContainer Div Element
phase'onMount' | 'onDestroy'Phase of DOM Element lifecycle
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext

Note

  • On onMount, return markup for AdapTable to inject into the panel container (context.element)
  • On onDestroy, return null and run any teardown (for example removing listeners attached to context.element)
Developer Guide

Providing Bespoke Tool Panel Content

Custom Tool Panel: Bespoke Content
Fork
  • Two Custom Tool Panels use render only (no buttons):
    • Hello World — static HTML returned from render
    • Application — an input rendered on onMount using CustomRenderContext lifecycle
  • The AdapTable Tool Panel opens on load

Caution

  • Unlike Dashboard Toolbars, the close button on a Tool Panel is always visible (and not configurable)
  • Module Tool Panels always display the Configure button; Custom Tool Panels do not

AdapTable Resources