Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No properties associated with the Filter object need to be accessed to utilise the API functionality.

Function Reference

getFilter(filterId)

Returns

FilterObject

Description

...

let filter = filters.get('47fe96c2-5101-4b0d-9018-7d12a84d3519');
console.log(filter.name, filter.uuid); //Output the name of the filter as well as its UUID


getAllFilters()

Returns

Object - {String, FilterObject}

...

This function is useful for observing which filters are available in the FiltersAPI. If you are looking for a specific filter it is recommended using filters.getFilter(filterId) rather than getAllFilters()[uuid] as getFilters can accept a UUID or a name. If you wish to iterate over all filters, we recommend using filters.forEach(fn) instead.


forEach(fn)

Returns

Nothing.

Description

...

This would create a list of applied filter values with the filter's name and uuid also included in the object.


hasFilters()

Returns

Boolean

Description

...

if(filters.hasFilters()) {
    generateMyCustomFilterPanel(filters);
}


clearFilter(filterId)

Returns

Nothing.

Description

...

UUID or Name of the filter you wish to clear.


clear() 

Returns

Nothing.

Description

Clears the values and applies the empty filter values in every FilterObject contained within the FiltersAPI.


applyFilters()

Returns

Nothing.

Description

...

document.querySelector('div#applyButton').addEventListener('click', function(e) {
    filters.applyFilters();
});


loadFilters()

Returns

Promise.

Description

Reloads filter data from the server. Promise is resolved once the filters have been loaded. 


resetFiltersToDefault()

Returns

Nothing.

Description

...

filters.resetFiltersToDefault();


addEventListener(eventName, callbackFunction)

Returns

Number.

Description

...

let eventListenerId = filters.addEventListener('changed', function(event) {
    console.log('One of my filters changed');
    filters.removeEventListener(eventListenerId);
});


removeEventListener(listenerId)

Returns

Nothing.

Description

...

let eventListenerId = filters.addEventListener('changed', function(event) {
    console.log('One of my filters changed');
    filters.removeEventListener(eventListenerId);
});



trigger(eventName, eventData)

Returns

Nothing.

Description

...

  • eventName - String - The name of the event that has been triggered. 
  • filterEvents - Array{Object} - An array of events that comprised this filter list change event. The object will contain at least the following.
    • uuid - UUID of the filter that changed.
    • filter - FilterObject that caused this event to trigger.
    • Certain other filter events can contain more information. You can see the documentation in FilterObject for more in depth details on the Event object for each event.


changed

Description

Triggered when any of the FilterObjects within the FiltersAPI changes its staged values.

...

let filters = report.filters;

filters.addEventListener('changed', function(event) {
        console.log(event.eventName); //'changed'
        console.log(event.filterEvents); //[{ uuid: 'a-filter-uuid', filter: FilterObject, changed: Object, previous Object }, {....}]
});

filters.setFilterValue('Demographic', ['Adventure']);


applied

Description

Triggered when any of the filters within the FiltersAPI has different values applied to it. This happens when the user hits the apply button, or the applyFilters function is called.

...

let filters = report.filters;

filters.addEventListener('applied', function(event) {
        console.log(event.eventName); //'applied'
        console.log(event.filterEvents); //[{ uuid: 'a-filter-uuid', filter: FilterObject, changed: Object, previous Object }, {....}]
});

filters.setFilterValue('Demographic', ['Adventure']);

filters.applyFilters();


reset

Description

Triggered when any of the FilterObjects within the FiltersAPI are reset.

...

let filters = report.filters;

filters.addEventListener('reset', function(event) {
        console.log(event.eventName); //'changed'
        console.log(event.filterEvents); //[{ uuid: 'a-filter-uuid', filter: FilterObject}, {....}]
});

filters.setFilterValue('Demographic', ['Adventure']);
filters.resetFiltersToDefault();

filters.getFilter('Demographic').reset(); //Trigger reset on an individual filter


cleared

Description

Triggered when any of the FilterObjects within the FiltersAPI are cleared.

...