Adaptable

#Dashboard

The dashboard is the chrome around the grid: bars of small widgets — view picker, quick search, buttons, row count, your own components — that give users quick access to Adaptable features.

There are four dashboards, one per side of the grid: top, bottom, left and right. Each is configured in the dashboard slice of the Adaptable state, and each is optional — a position without widgets renders nothing.

A top and a bottom dashboard
dashboard: {
  top: {
    widgets: [
      { id: 'view', type: 'view' },
      { id: 'quickSearch', type: 'quickSearch', align: 'center' },
    ],
  },
  bottom: {
    widgets: [{ id: 'row-count', type: 'row-count' }],
  },
},

Every widget needs a unique id and a type. Some types take a value with their configuration (the button's label and handler, the ribbon's tabs, …).

#
A dashboard above and below the grid

The top bar shows the application name, the view picker, quick search (centered) and the dashboard settings button (at the end). The bottom bar shows the row count and a cell summary — select a few salary cells to see their sum.

open
loading demo…

#Positions, bars and drawers

top and bottom dashboards lay their widgets out horizontally; left and right lay them out vertically, so widgets there are more compact — usually just an icon button that opens the matching settings page.

Each dashboard has two parts:

  • the bar — the always-visible strip of widgets;
  • the drawer — an area next to the bar that opens when the user clicks a tab of the ribbon, showing that tab's widgets with more room.

Within the bar, align places a widget in the start (default), center or end section.

A dashboard section also accepts:

  • disableResize — stops users from resizing the drawer by dragging its edge;
  • hidden — hides the dashboard but keeps its widgets and style, so it can be shown again as it was;
  • size — bar and drawer sizes in pixels (the height for top/bottom, the width for left/right);
  • style — colors for the bar (bar.background, bar.color, bar.buttonColor) and the ribbon tabs (tabs.background).

#Widget types

General widgets:

TypeShows
application-nameThe config.applicationName from state
row-countThe number of rows (after filtering); in server mode, the count the server sends
selected-row-countThe number of selected rows, from rowSelectionApi.getSelectedRowCount()
grid-filterThe current view's grid filter expression
column-chooserPick and reorder the view's columns (compact in bars, full in a vertical drawer)
buttonA button — see Buttons and info
infoCustom text or content
ribbonA strip of tabs that open the drawer — see Ribbon tabs
customA widget from dashboard.customWidgets — see Custom widgets
custom-contentInline custom content

Module widgets — one per Adaptable module. In a bar they show a button that opens the module's settings page — next to the control itself for view, quickSearch, theme and export in horizontal bars (cell-summary shows its value in every bar). In a drawer they show the full control:

TypeShows
viewThe view picker
quickSearchThe quick search input
themeThe theme picker
exportThe report picker, with run, edit, delete and new buttons
cell-summaryAn aggregation (sum, avg, …) of the selected cells
dashboardOpens the dashboard settings for this position
settingsPanelOpens the settings panel
styledCell, flashingCell, calculatedColumn, alertOpen the matching settings page

The cell-summary widget needs a view with multi-cell selection. Its value is the aggregation to show — 'sum', 'avg', 'min', 'max', 'distinct' or 'count' — or an object { fn, label, formatter, showDropdown }; users can switch the aggregation from its dropdown.

Note

Module widgets respect the modules prop and user permissions: a widget whose module is excluded, or which the current user has no permissions for, is not rendered. See Permissioning.

#Ribbon tabs

The ribbon widget works like the Microsoft Office ribbon: it adds a row of tab names to the bar, and clicking a tab opens the drawer with that tab's widgets. Clicking the open tab again closes the drawer.

A ribbon with two tabs
{
  id: 'ribbon',
  type: 'ribbon',
  value: {
    openTabName: 'Views', // the tab open initially — omit to start closed
    tabs: [
      {
        name: 'Views',
        widgets: [{ id: 'view', type: 'view' }, { id: 'theme', type: 'theme' }],
      },
      { name: 'Export', widgets: [{ id: 'export', type: 'export' }] },
    ],
  },
};

Each dashboard has at most one ribbon (only the first ribbon widget in a bar is used), and only one of its tabs is open at a time. The open tab is part of the state, so it persists like everything else.

#
Ribbons at the top and on the right

The top ribbon has a Views tab (view and theme pickers) and an Export tab. The right ribbon opens a column chooser — the full list of columns fits in a vertical drawer. Click a tab to close or open its drawer, and drag the drawer edge to resize it.

open
loading demo…

#Buttons and info

The button widget renders a button. Its value takes:

  • label — text or something to render (an <ng-template> passed with renderTemplate(tpl), a component with renderComponent(Cmp)), or a function returning one;
  • onClick — called with the widget props (see below), so the handler has the Adaptable API and the dashboard position at hand;
  • tone — 'success', 'error', 'warning', 'info', 'accent', 'default', 'neutral' or 'none';
  • variant — 'text', 'outlined' or 'contained'.

The info widget shows its value — a string or something to render. Both widgets follow the orientation of their dashboard: horizontal at the top and bottom, vertical on the sides.

#
Buttons and info in every position

The same info text and two buttons in each of the four dashboards. Edit opens the dashboard settings on the position the button sits in.

open
loading demo…

#Custom widgets

Render your own components in the dashboard in one of two ways:

  • Reusable — register them in dashboard.customWidgets (a component class, an <ng-template> of the widget props, or something to render, by key) and place them with a custom widget whose value is that key. The same custom widget can be placed in several positions.
  • Inline — a custom-content widget whose value is something to render or a function of the widget props that returns it, such as (props) => renderTemplate(tpl, props).

A template from your component's own template is read with viewChild, so a state that refers to one is built in the component (a field initializer is fine: the function is only called when the widget renders).

Registering and placing custom widgets
dashboard: {
  customWidgets: {
    // a component class, a template (TemplateRef) of the widget props, or something to render
    'current-view': CurrentViewBadge,
  },
  top: {
    widgets: [
      { id: 'badge', type: 'custom', value: 'current-view' },
      // <ng-template #hello><b>Hello</b></ng-template>, read with viewChild
      { id: 'hello', type: 'custom-content', value: () => renderTemplate(this.hello()) },
    ],
  },
},

Custom widgets receive WidgetProps (exported from the package):

type WidgetProps = {
  api: AdaptableApi; // the Adaptable API
  section: DashboardSection; // the dashboard's config
  sectionPosition: 'top' | 'bottom' | 'left' | 'right';
  location: 'dashboard-bar' | 'dashboard-drawer';
  orientation: 'horizontal' | 'vertical';
  widgetId: string;
  widgetType: string;
};

Because they render inside <adaptable-provider>, custom widget components can also call the Adaptable inject functions, such as injectAdaptableState() or injectAdaptableApi(). A widget component gets the widget props as inputs of the same names, and only the ones it declares: extend WidgetInputs (exported from the package) to declare them all.

A widget component
// a reusable widget: extending WidgetInputs declares the widget props as inputs
@Component({
  selector: 'current-view-badge',
  template: `<span [attr.data-orientation]="orientation()">View: <b>{{ viewId() }}</b></span>`,
})
export class CurrentViewBadge extends WidgetInputs {
  protected readonly viewId = injectAdaptableState((state) => state.view.currentViewId);
}

A template registered as a custom widget gets the widget props as its context (let-orientation="orientation", or the whole object with let-props).

#
Custom widgets

CurrentViewBadge is registered once in customWidgets and placed in the top and left dashboards — it reads the orientation from its inputs to lay itself out vertically on the side. The bottom bar holds an inline custom-content widget, rendered from an <ng-template>. Switch views to see the badge update.

open
loading demo…

#Editing the dashboard

The Dashboard page of the settings panel lets users lay out all four dashboards: a map of the positions around the grid to pick one and show or hide it, and for the selected position:

  • Widgets — drag widgets into the start, center or end of the bar;
  • Ribbon — add the ribbon, create tabs and drag widgets into them;
  • Style — the bar and tab colors.

A position can also be removed entirely, discarding its widgets, tabs and style.

Users can add the module widgets, row-count, selected-row-count, application-name and the ribbon to a bar, and the module widgets and column-chooser to ribbon tabs. Everything else — buttons, info, custom widgets — is placed by developers: users can move those widgets around but not remove them.

The same editor is available standalone as <adaptable-dashboard-manager> (DashboardManager), and the dashboard widget opens it on its own position.

#Placing the dashboards yourself

<adaptable-ui /> renders the four dashboards around the grid for you. For a custom layout, render the pieces yourself inside <adaptable-provider>:

<adaptable-provider adaptableId="my-app" primaryKey="id" [data]="data" [defaultState]="defaultState">
  <!-- the four dashboards around the grid -->
  <adaptable-dashboard>
    <adaptable-data-grid />
  </adaptable-dashboard>
  <!-- settings dialog, notifications and cell notes -->
  <adaptable-overlays />
</adaptable-provider>

<adaptable-dashboard-top>, -bottom, -left and -right (AdaptableDashboardTop, …) render a single dashboard, so you can place one anywhere in your app — pass [slots]="false" to <adaptable-dashboard> to render only its content in the grid area.

#Dashboard API

adaptableApi.dashboardApi changes the dashboards at runtime:

const { dashboardApi } = adaptableApi;

dashboardApi.setDashboardBarWidgets('bottom', [{ id: 'row-count', type: 'row-count' }]);
// replaces the tabs of the ribbon already in the top bar
dashboardApi.setDashboardTabs('top', [{ name: 'Views', widgets: [{ id: 'view', type: 'view' }] }]);
dashboardApi.setOpenTabName('top', 'Views'); // null closes the drawer
dashboardApi.setDashboardStyle('top', { bar: { background: '#1d4ed8', color: 'white' } });
dashboardApi.setDashboardHidden('left', true); // keeps its widgets
dashboardApi.removeDashboard('right'); // discards widgets, tabs and style

The full dashboard state is described in the state reference.