Hello,
I have a question regarding a report that has a filter. However, when the data does not contain the specific value to be filtered, the filter is ignored and the report shows me the data that I actually requested not to appear.
I have created a demonstration where I reload the data using two buttons. The "setData1" button works correctly because the filter has the value "red" and displays the data correctly. However, the "setData2" button does not work properly as the data does not have the value "red" and ends up showing the "blue" and "green" data that I filtered out.
Demonstration: https://jsfiddle.net/u206ehak/2/
I would like to know if I am making any mistakes in configuring the filter.
Thank you in advance for your response!
Best regards, Willians Cirilo
Hello, Willians!
Thank you for contacting us.
Kindly note that when there is no specific data for the filter, the filter is considered invalid in Flexmonster, and all the data is shown.
If you want to show an empty grid instead, please look through our guide on this case: https://www.flexmonster.com/doc/advanced-tips-filtering/#show-empty-grid-when-filtering-by-non-existent-members.
Hope you will find our answer helpful.
Kind regards,
Solomiia
Hello Solomiia,
I hope you're doing well. I wanted to discuss some doubts related to the functioning of filters in Flexmonster.
I appreciate your response and guidance in advance.
Best regards,
Willians Cirilo
Hello, Willians!
Thank you for getting back to us.
Please find answers to your questions below:
1. The report can be saved and restored using getReport()
API call, as well as the Save
button on the Toolbar.
You can find more details about saving and restoring reports on the following page: https://www.flexmonster.com/doc/save-and-restore-report/.
2. Regarding the invalid filter alert, please note that if no members in the filter match the data, then the filter is just not applied. This is the expected filtering behavior, and we're not considering it an error.
If you would like to show a pop-up message when the filter didn't get applied, we suggest checking if the filter is present in the report and displaying the alert if needed.
We have prepared a JSFiddle sample to illustrate the idea: https://jsfiddle.net/flexmonster/pv6kgwm5/.
Could you please let us know if the suggested approach works for your case?
Looking forward to hearing from you.
Kind regards,
Solomiia
Hello Solomiia,
I apologize for my previous expression:
Regarding the first question, my doubt is about the usage described in https://www.flexmonster.com/doc/advanced-tips-filtering/#show-empty-grid-when-filtering-by-non-existent-members. It mentions the use of the include property and query: { equal: "" }, but by default, Flexmonster uses the members property.
As for the second question, I appreciate the suggestion of displaying an alert message. However, as I mentioned before, the report is dynamically generated by the end user. Therefore, I need a generic alert as I don't know which filter the user will use to indicate the field.
Once again, thank you for your help and response.
Best regards, Willians Cirilo
Hello, Willians!
Thank you for the details about your use case.
Kindly note that when filtering members from the UI, only members present in the dataset are listed in the Filters pop-up. Therefore the clients have no chance to filter by non-existent members.
Could you please let us know if you are using any other filtering methods aside from our default UI pop-up? This would help us greatly to continue the investigation.
Looking forward to hearing from you.
Kind regards,
Solomiia
Hello Solomiia,
I hope you're doing well.
In fact, we only use the default filter from the UI pop-up. This filter meets the needs of most use cases and provides a simplified experience for our users.
If you have any suggestions you would like to share with us, please don't hesitate to let us know. We are always looking for ways to improve and meet the needs of our users.
Thank you for your attention and collaboration.
Best regards, Willians Cirilo
Hello, Willians!
Thank you for the details about your use case.
As we understand, the described behavior with no data for the filter appears when changing the data using setReport()
API call with your custom controls.
We had prepared a JSFiddle example with a generic alert message, so the users would know that their previous filter was cleared when the data was changed: https://jsfiddle.net/flexmonster/oqg56b4k/.
In this example, the getAllHierarchies()
API call was used to retrieve all fields. Then, we get all existing filters iterating on fields with the getFilter()
API call. After the data is changed and a new report is loaded, we compare the filters and show the alert pop-up if any of them is missing.
Hope it helps.
Please let us know if the suggested approach satisfies your needs.
Kind regards,
Solomiia
Hello Solomiia,
I hope you're doing well.
Your example meets our needs. Thank you very much for your attention and collaboration.
Best regards, Willians Cirilo
Hello, Willians!
Thank you for your feedback.
We are glad to hear the suggested approach works for you.
Feel free to contact us in case of any other questions.
Kind regards,
Solomiia
Hello, Willians!
Hope this letter finds you well.
The Flexmonster team is happy to let you know that we’ve recently added a new functionality to our pivot grid, which we believe you might find valuable.
For the JSON and CSV data sources, we have added a new filter.allowEmptyMembersFilter option starting from the 2.9.86
version of Flexmonster. This property allows to show an empty table when the selection filter includes only members that do not exist in the dataset instead of removing the invalid filter.
So, if this approach matches your data source type(JSON or CSV), you are welcome to use it instead of the workaround we provided earlier. For other data source types, we recommend sticking to the approach of combining member and query filters.
Here is the JSFiddle to illustrate the idea: https://jsfiddle.net/flexmonster/vkthmug4/.
You can find more details about the new filtering functionality in our docs: https://www.flexmonster.com/doc/advanced-tips-filtering/#show-empty-grid-when-filtering-by-non-existent-members.
Feel free to explore the new property, and if you have any questions or feedback, we’d be happy to assist.
Kind regards,
Solomiia
Hello, Solomiia,
Thank you for reaching out and for introducing the new functionality in Flexmonster. I'm happy to see continuous improvements in the tool.
I’ve had a chance to explore the new filter.allowEmptyMembersFilter option, and it fits perfectly with my current use case, as I primarily work with CSV data sources. This addition is very welcome and simplifies the implementation significantly compared to the workaround we used previously.
However, I noticed one point that might need further consideration. When applying a filter with filter.allowEmptyMembersFilter enabled, the filter UI does not display the members that are present in the members array. This could potentially lead to some confusion, as the filter doesn’t visually reflect the selected members. It would be helpful if the filter UI could somehow indicate the members being filtered, even if they don't exist in the dataset.
Please let me know if there is any additional configuration to address this, or if it’s something planned for future releases. Once again, I appreciate the update and the opportunity to provide feedback.
Kind regards,
Willians
Hello, Willians!
Thank you for getting back to us.
We are happy to hear our new property works well for you.
Regarding your request, we have added a feature of showing the filtered members in the field pop-up even if they are not present in the data to our Customers' Wishlist. Our team will notify you if there are any updates on the matter.
Feel free to reach out to us if any other questions arise.
Kind regards,
Solomiia