How to Create Dependent Filters in Explo
Last updated: November 27, 2024
Explo allows you to create dependent filters, where the options in one filter depend on the selection made in another filter. This can be useful when you have hierarchical data or want to provide a more guided filtering experience.
Using the Built-in Dependency Feature
The simplest way to set up dependent filters is to use Explo's built-in dependency feature:
Open the dashboard and go to the Preferences tab.
For the filter that should depend on another, enable the "Dependency Selection" option.
Select the filter that this filter depends on.
With this setting enabled, the dependent filter will be disabled until a value is selected in the filter it depends on.
Using JavaScript for Faster Loading
If you find that the dependent filter takes too long to populate after selecting a value in the main filter, you can use JavaScript to dynamically update the options. This can provide a snappier experience for the user.
To do this, you'll need to listen for the sendVariableUpdatedEvent from the main filter. In the event handler, you can update the options of the dependent filter using updateExploDashboardVariable.
Keep in mind that even with this approach, you'll still need to call updateExploDashboardVariable to set the value of the dependent filter after the user makes a selection.