Displaying Custom Windows
Summary
- AdapTable allows developers to provide custom windows
- These are custom, movable, resizable with bespoke content
AdapTable allows developers to create and display bespoke Windows.
These windows display bespoke content supplied by the developer.
Hint
- Custom Windows are fully movable and resizable
- If a user moves or resizes a window, it re-opens with those dimensions and position
Open and close Custom Windows via User Interface API:
openCustomWindowPopup— displays a Custom Window using the suppliedCustomWindowConfigcloseCustomWindowPopup— closes the open window with the givenid
Deep Dive
The Custom Window object
Developer Guide
Providing a Custom Window
const config: CustomWindowConfig = {
id: 'demo_window',
title: 'Demo Window',
icon: 'laptop',
position: {x: 100, y: 100},
size: {width: 400, height: 300},
render: context => {
if (context.phase === 'onMount') {
return '<div style="padding:10px"><p>Custom window content</p></div>';
}
return null;
},
};1
Create Custom Window Config
Build a CustomWindowConfig:
id— required unique identifier; pass the same value tocloseCustomWindowPopuptitle— label shown in the window headericon— optionalAdaptableSystemIconNamefor the header (e.g.'laptop','search')position— optional initial placement in pixels (x,y) —WindowPositionsize— optional initial dimensions (width,height) —WindowSizerender— function returning HTML; receivesCustomRenderContext(phase,element,adaptableApi). Return markup on'onMount'; returnnullon'onDestroy'.
Users can move and resize the window at run time; AdapTable restores the last position and size when the window opens again.
onClick: (button, context) => {
context.adaptableApi.userInterfaceApi.openCustomWindowPopup(config);
},2
Open from application code (e.g. a Dashboard or Toolbar Button)
Call openCustomWindowPopup wherever you have adaptableApi — commonly in a Custom Toolbar Button or Custom Dashboard Button onClick handler.
setTimeout(() => {
context.adaptableApi.userInterfaceApi.closeCustomWindowPopup('demo_window');
}, 10000);3
Optionally close the window programmatically
A close button is always shown in the header (not configurable). To close from code, call closeCustomWindowPopup with the config id (for example after a timeout).
Creating a Custom Window
- This example contains a Custom Dashboard Button -
Show Custom Window- which opens a Custom Window popup that displays the rendered content that was provided - The Custom Window is given an initial Size and Position but is also fully movable and resizable by the run-time user
- The Custom Window contains a Close button for manual close, but is also set programmatically to close after 10 seconds (via
closeCustomWindowPopup)
Try It Out
- Click Show Custom Window — the window opens at the configured position and size; move and resize it as needed
- Wait 10 seconds — the window closes automatically via
closeCustomWindowPopup - Open it again — it restores the position and size you last set
Find Out More
It is also possible to display Progress Indicators when running a long task