Alert Message

Summary

  • AdapTable dynamically creates an Alert Message (containing Header and Text) each time an Alert is triggered
  • This Alert Message can be overridden by users who can provide custom text; this can be done in 2 ways:
    • via the Alert Definition
    • using Alert Options

When an Alert fires, AdapTable provides an accompaying message describing why it was triggered.

This Alert Message - is created by AdapTable automatically - and is formed of 2 parts:

  • Alert Header - a brief description of the Alert
  • Alert Text - more information about what took place to trigger the Alert

Note

  • The Alert Message is displayed in all the Alert related UI controls
  • i.e. in the Toolbar, Tool Panel, Status Bar - and most notably in the Alert Notification

Custom Alert Message

As noted above, AdapTable will create the Alert Message automatically, based on the Alert Definition and the action that triggered the Alert.

However users are able to override this behaviour and to supply a custom Alert Message.

This bespoke Alert Message can be provide in 2 different ways:

  • as properties in the Alert Definition (run-time or design-time)
  • via a function in Alert Options (design-time only)

Alert Definition

The most straightforward way to override the automated Alert Message is via the Alert Definition.

There are 2 properties that can be provided:

  • MessageHeader - allows a custom Header to be displayed
  • MessageText - allows custom Text to be shown in the Message

Note

These properties are available both to the developer at design time and the end user at run-time

Custom Alert Messages (Definition)
Fork
  • This demo shows how to provide a Custom Alert Message Header and Text using the Alert Definition
  • A Warning Alert fires any time a value is changed in the Language Column
  • We provide a Custom Header and Message in the Alert Definition

Expand to see the Alert Definition

Try It Out
  • Edit a cell in the Language Column and see the Alert with the custom Header and Text messages
  • Note: The text displayed is the same every time the Alert fires (regardless of the row)

Messages using Templates

The Custom Alert Message in the Alert Definition can be provided with Template Literals.

AdapTable automatically replaces these templates, using string interpolation, with the relevant text when the Alert Message displays.

This enables the Alert Message to display "dynamic" content, that changes for each Alert.

Hint

Template Literals can be used in both parts of the Alert Message: Header and Text

AdapTable provides two sets of Message Templates - one which can be used in both Data Change and Aggregation Alerts, and the other which is designed for Row Change Alerts:

Template LiteralDescriptionData Change & AggregationRow Change
[newValue]New value for changed cell
[oldValue]Old value for changed cell
[column]Name of Changed Column
[primaryKeyValue]Primary Key value of Row
[timestamp]Timestamp when Alert triggered
[trigger]What caused Alert to fire
[numberOfRows]Count of Rows added or deleted
[rowData.x]Changed Row (e.g. [rowData.price])
[context.x]Any AG Grid context provided (e.g. [context.name])

Note

  • [trigger] values that can be returned for Data Change & Aggregation Alerts are: Edit, Tick, Undo, AggChange
  • [trigger] values that can be returned for Row Change Alerts are: Added, Edited, Deleted, Loaded
Custom Alert Messages (Templates)
Fork
  • This demo shows how to provide a Custom Alert Message using the Alert Definition with Template Literals
  • We have created 3 Alerts each of which provides a custom Header or Text (or both) using different Template Literal props:
    • A Warning Data Change Alert fires any time a value is changed in the Language Column - with templates in both Message Header and Text
    • A Success Row Change Alert fires when a new Row is added (can by triggered by "Add Python" button in Dashboard) - with template in Message Text
    • An Info Aggregation Alert fires when the lowest row in the Github Watchers column is less than 50 - with template in Message Header

Alert Options

Alert Definition Template Literals are sufficient to meet most use cases where a different Message is required to appear each time the Alert is triggered.

However if greater custom flexibility is required, developers can create a completely dynamic Message with any text - via 2 function properties in Alert Options:

Note

Both functions receive Context describing the Change that triggered the Alert (and associated Alert Definition)

  • alertMessageHeader - allows developers to provide a custom message header
  • alertMessageText - allows developers to provide custom message text

alertMessageHeader

String
Function providing a Header to display for an Alert

alertMessageText

String
Function providing a Message to display in an Alert

Caution

  • These 2 properties are only available for Alerts created at Design-Time and cannot be set in the UI
  • This is because Alert State is saved as JSON which needs to be stringified (and cannot include functions)
Custom Alert Messages (Options)
Fork
  • This demo shows how to provide a Custom Message Header and Text via Alert Options - so that they are diferent each time the Alert fires:
  • An Info Alert fires when any value is changed in the Github Stars column
  • The Custom Header references the RowData to get the Framework in the row where the change was made
  • The Custom Text references the new value that has been given to the Cell which triggered the Alert

Expand to see the Custom Header and Text Messages provided

Try It Out
  • Edit a cell in the Github Stars Column and see the Alert with the custom Header and Text messages
  • Note the Alert Message is different for eaach row in the Grid

Custom Alert Messages

(Recorded with AdapTable v14.0)