We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Report Filter

Re-Open
Jason Lewis asked on January 6, 2022

I am able to add a filter to my pivot table for a category that is already displaying data by using setFilter. For example, in the code below it will only show the selected warehouse
 

                flex_dataTable.setFilter("Warehouse",
                                                        {
                                                            "members": [
                                                                            "category.[Warehouse 1]"
                                                            ]
                                                        }
                );

 
My problem is when I have a view that does not include the Warehouse category. The filter does nothing. Using the UI I can make the change by adding a Report Filter. How can I use the API to automatically add a ReportFilter for the Warehouse category?

5 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 10, 2022

Hi, Jason!
Thank you for your question.
Though Flexmonster API does not provide a method for setting a report filter, there is a way to add it with the API. You can get the report object using the getReport method and then embed the reportFilters object into a slice object. Then use the runQuery method to apply changes in a slice object.
Please refer to this code as an example:
https://jsfiddle.net/flexmonster/1j6pwbv9/
Feel free to contact us in case any questions occur.
 
Best Regards,
Maksym  

Public
Jason Lewis January 12, 2022

Thanks for the update, this helps.
My issue is I am giving the user the option to change the layout of the pivot table by selecting from several view options. Some of those view options show the column the user wants to filter on and some of them do not. It appears that if the column is shown in the pivot table I need to apply a filter but if the column is not shown in the pivot table I need to apply a report filter. Is there a way to tell if I need to apply a filter vs a report filter and is there a way to clear any filters or report filters applied to the pivot table?
Thanks.

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 13, 2022

Hi, Jason!
 
Thank you for your feedback. As you correctly mentioned in your reply, you apply a filter if a column is shown on the table and a report filter if it isn't. 
There are two ways of removing filters in Flexmonster:

  1. Via clearFilter(hierarchyName: String) API call, you can clear all filters that you applied on a specific hierarchy. This function also works on Report Filters.
  2. You can use the same approach I described earlier. You can get a report object with the getReport method, remove filters from JSON and save changes with the runQuery API call.

Please check this example with both ways of removing filters on JSFiddle.
 
I hope you will find my answer helpful.
 
Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 17, 2022

Hi, Jason!
 
Hope you’re doing well.
Just checking in to ask if everything works fine for you.
 
Best Regards,
Maksym

Public
Jason Lewis January 17, 2022

Yes, everything is going well. Your information on filters was a big help.
 
Thanks.

Please login or Register to Submit Answer