Event Handlers
Event handlers allow you to trigger queries, open web pages, and perform other actions in response to user interactions. You can add event handlers to components, for example you can add a Change event to a button that allows you to specify an SQL query to be ran when that button is pressed.
Component Events
To create an event handler, select your component then under the interactive section, click "Add Event Handler".
The available events depend on the selected component.
- Tables support click and menu events
- Charts support click events
- Form elements e.g. buttons/selects/sliders support change events
Every action handler provides the ability to run queries and/or open a URL. These are configured using the properties:
Property | Description |
---|---|
Trigger | What triggers the action to occur. "Click","Menu" or "Change". |
Name | The name of the action. For menu, this is the text shown in the context menu. |
Data Source | The data source that will be sent the query. |
Data Query | The query to be ran. This can contain variables including event variables. |
URL | If specified this URL will either be opened in the same window or a new window. This URL can contain variables. |
Events Variables
As well as the usual global variables, event handlers receive a special "e" variable that contains data related to that event. For example when a Click or Menu event handler is added to a table, it will receive an e variable with all data for that row. The easiest place to see what this contains is in the debug console.
[[KDB Database only]] Using the full variable ((e)) in a query, where there exists values for e.name/e.val/e.YYY etc. will send a dictionary of all those values to the kdb process
Event Return Values
Event handlers can return values and Pulse will attempt to display a representation of them in a small popup alert. If a table with a single row and column is returned, that text will be the content of the popup. If you return more rows or columns, Pulse will show a tiny sample.