Skip to content

Filters

Matt Mazzola edited this page Aug 11, 2016 · 25 revisions

As you may have read from the Embed Configuration Details page, you can apply additional filters when loading a report. You can also change filters dynamically which allows you to create your own custom filter pane which can match the brand of your application or automatically apply filters on some other context of your application to help show the user the correct visual/information.

Retrieving filters:

report.getFilters()
 .then(filters => {
     ...
 });

Applying filters:

const filter = { ... };

report.setFilters([filter])
  .catch(errors => {
    // Handle error
  });

Keeping your application in sync with the report

When building a custom filter pane control it will be required to keep this updated with the state of the report. You can do this by adding an event handler for the filtersApplied event as shown below:

report.on('filtersApplied', event => {
   const filters = event.details.filters;
   this.appliedFilters = filters;
});

Removing Filters

report.removeFilters();

Page Level and Visual Level filters

As you may have read in Understanding the Object Hierarchy report, page, and visual objects all implement the IFilterable interface which means each of these objects can also use getFilters, setFilters, and removeFilters just like reports.

It's important to understand that all of these filters are independent and adding or removing to one level does not implicitly change another.