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
Add Event Handler

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.
Edit Event handler

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.

Event Variables

[[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.

Download Buttons and Actions

Event handlers can trigger file downloads for the user. These work by the author returning a particular table structure from any action. This enables you to provide PDF downloads, custom text downloads or any form of download where you can fully control the content.

For full details and examples see our Download button article.

Configure a query to return:

Column Type Description
data (Required) Text string, kdb byte array or "base64," encoded string. The content of what will be downloaded.
name (Optional) string File name that user will see downloaded.
mimeType string The MIME type of the file. Pulse will automatically detect pdf/txt/jpg/png if the filename is specified.