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?
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
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.
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:
clearFilter(hierarchyName: String)
API call, you can clear all filters that you applied on a specific hierarchy. This function also works on Report Filters.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
Hi, Jason!
Hope you’re doing well.
Just checking in to ask if everything works fine for you.
Best Regards,
Maksym
Yes, everything is going well. Your information on filters was a big help.
Thanks.