Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Setting filter options without table data

Re-Open
Vinicius asked on March 17, 2021

Hello,
We’ve been using the trial version for a few days, trying to update our filters and tables to flexmonster’s and one of the requests of my employer is to filter data through the table columns from an empty table.
With an empty table, we would like to click each column and send a GET request to our API with the selected column as parameter and receive the possible filters for that column, without bringing all the data.
We would like to populate the filter list with the response and, after the desirable filter options are selected, a request is sent when the user clicks the “Apply” button on the filter modal and the table data is retrieved with the selected filters.

I was able to make the request to the server when opening the column filter, but by using the method setFilter() for that column, the filter modal is closed and I get an error informing that those members do not exist because they are not loaded as table data.
After the response with table data is obtained, we would load the table with pagination and each subsequent filter is applied the same way.
We would be grateful if you could tell us if this is possible to achieve and any assistance on how we can accomplish it would be greatly appreciated.

2 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster March 18, 2021

Hello,
 
Thank you for contacting us.
 
If we understand correctly, your requirement is to apply filtering before loading the data to the component for the first time. In case our assumption is correct, please see the following explanation.
 
Currently, built-in UI controls do not allow pre-filtering.
However, we have come up with a workaround that may work for you.
It implies developing a custom Field List that would allow the required functionality.
You are welcome to see the sample implementation of this approach by the link: https://jsfiddle.net/flexmonster/7qazjk6s/.
 
A detailed explanation of the approach can be found below.
On the initial load, retrieve all the fields using the getAllHierarchies API call.
Having the enumeration of all fields, it is possible to compose and display the custom Field List.
After the user choose what field needs to be used for filtering, execute the getMembers method to receive the list of members for this field. Use this information to configure the corresponding filtering UI controls. Complement the filtering view with a label filter if needed.
 
To summarize, the process will look like this:

  1. Open an empty report without a slice specified.
  2. Execute the getAllHierarchies method and receive the list of all hierarchies.
  3. Display the custom Field List with all the received fields. Display filtering button for each field.
  4. After the user clicks on the filtering button, execute the getMembers method.
  5. Display the custom filtering window with all the received members of the chosen field.
  6. After the user applies filtering rules for chosen fields, compose the Slice Object and include appropriate Filter Objects.
  7. Apply the configured slice using the runQuery API call.

 
Please let us know if it works for you.
Our team is looking forward to hearing from you.
 
Kind regards,
Illia

Public
Vinicius March 24, 2021

Hello, Illia. Thank you, that was incredibly helpful.

Please login or Register to Submit Answer