Loading with filters


#1

Hello community

I have a small app with a couple of visualizations and the filter control. I want the application to be loaded with filters. I was able to do that by creating the filters object and setting that to each visual with .filters(). The problem is that they are not shown in the filter control, so the apps have filters applied but the filter control doesn’t know about them. How can they be also loaded to have everything in sync?


#2

What you are looking for is the exposed API of the filter control. Specifically the .setFilters() method.


#3

Hi @eduardo, thanks for your response. I used the setFilters() method and it did work as advertised. I reviewed the documentation and I saw also about the applyFilters() function, that triggers the filters when they are set to the Filter Control.

What would be your recommended way to apply (load) the initial filters? setting them and applying them (.setFilters() + applyFilters()) or use the .filters() function from the beginning?

Also, wouldn’t be better for consistency to call the function .filters() instead of .setFilters() and apply them all in one single step?


#4

Well for your first question, the right way would be to use .filters() on each visualization since they will do only one request per visual including the filters the first time they load. You still have to use .setFilters() to keep the Filter Control in sync. If you use .applyFilters() all visuals will query the server initially with no filters and immediately a second query will be triggered to then filter the visuals.

About your second question, there are two main reasons. The first one is that the specialty of the FC (which by the way will be renamed to Interaction Manager in next releases) is to handle filters, so it would be too generic and maybe confusing, that’s why we have getFilters, setFilters, removeFilters… and other methods with more explicit and intuitive names. The second reason is that most of the time filters are only set (at load time) in the FC and not triggered from there to avoid additional queries as specified in my first response, and you always have setFilters + applyFilters to do it if you really need to.


#5

If I have a set of filters that are loaded with my application, are they meant to be removed after by the Filter Control? I though that the point of setting initial filters at loading time was to have them persisting thru the entire workflow.

Can I somehow tell the Filter Control that certain filters are “fixed” ?


#6

I think what you are looking for is the static filters. I see they are a perfect fit since they can be replaced with your own filters if they match the field, and if you remove your filters after, the static will stay. However I don’t know if they can be handled or removed somehow.


pinned #7