Custom interactive filter example

As an administrator, you can create custom interactive filter widgets to provide advanced filtering options on dashboards.

Use case

This example details how to create a custom filter that filters reports on the Task table, or child tables, to show only records where the current user is the caller. The filter exposes two buttons to the user, one button to add the filter and one to remove the filter.

Create the widget

To create a custom filter, you must create a new dynamic content record and define the user interface for the filter.

Add any buttons or other interface elements to the widget.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Example of a filter, that generates a static filter on 'task' table reports, or remove it <br/>
<input id="allTasks" type="button" value="All tasks" />
<input id="onlyMine" type="button" value="Only mine" />
</j:jelly>

Define the filtering logic

After defining the buttons or other elements visible to users, define how each option filters reports on the dashboard.

Filters use the DashboardMessageHander class to manage active filters.

The Only mine button publishes a filter on Task table reports using the encoded query caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe. The All tasks button
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
 var my_dashboardMessageHandler = new DashboardMessageHandler("my_unique_id");
</script>
Example of a filter, that generates a static filter on 'task' table reports, or remove it <br/>
<input id="allTasks" type="button" value="All tasks" onclick="my_dashboardMessageHandler.removeFilter();" />
<input id="onlyMine" type="button" value="Only mine" onclick="my_dashboardMessageHandler.publishFilter('task','caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe');" />
</j:jelly>

Add the filter to a dashboard

After creating the filter, add it to a dashboard that contains reports on the Task table or child tables.

Clicking the Only mine button on the filter filters reports on the dashboard to only show tasks where the current user is the caller.

Figure 1. The custom filter