filters are ignore when non-exists values passed to filter

Answered
Nil asked on December 14, 2021

Hi Team,
 
We are applying dynamic filters on flat type grid.
When we are passing non existing values then it simply ignore and load add the data .
data source is flexmonster data server  
How shall we load blank grid if any filter does not get matched. 
please consider this example 
https://jsfiddle.net/awf25ne4/29/ 
{
"uniqueName": "Country",
"filter": {
"negation": false,
"members": [
"country.[australia1]",
]
}
} ,
 
"slice": {
"columns": [{
"uniqueName": "Country",
"filter": {
"negation": false,
"members": [
"country.[australia1]",
]
}
},
 
If above filter applied then it is loading all values .
 Kindly look and suggest any approach to achieve this issue . 

3 answers

Public
Vera Didenko Vera Didenko Flexmonster December 14, 2021

Hello, Nil,
 
Thank you for your question.
 
We would like to explain that this is the expected behavior when filtering by members: when none of the members that are specified in the filter exist, Flexmonster doesn't apply the filter.
 
A possible solution would be to use the query filter type instead of filtering by members, for example:

uniqueName: "Country",
filter: {
query: {
equal: "Australia1"
}
}

As a result, an empty table will be displayed if none of the members match the specified string. For more details on the available filtering options, please see our Filter Object documentation
 
 
Please let us know if this helps.
 
Kind regards,
Vera

Public
Nil December 14, 2021

Thanks Vera  for update ,
 
but here we have multiple filter not a single 
here how we can specify multiple options 

uniqueName: "Country",
filter: {
   query: {
      equal: "Australia1","Canada1"
   }
}
Public
Vera Didenko Vera Didenko Flexmonster December 15, 2021

Hello, Nil,
 
Thank you for your reply.
 
Currently, the "equal" query filter accepts a single string input.
 
However, there is a workaround allowing to apply a multi-value filter that will display an empty grid if none of the values exist.
The idea lies in the following:
It is possible to get the list of all members that exist in a hierarchy with the getMembers() API call.
With this in mind, you could check if at least one of the passed values exists in the searched field. If at least one value exists, proceed with a members filter. In case no values are found in the members' list, proceed with an "equal" query filter and pass any non-existent value from the search query to it (for example, the first value).
Here is a simple JSFiddle example demonstrating the described approach: https://jsfiddle.net/flexmonster/oakp6hvs/.
 
Alternatively, you could provide a dropdown input from which users should select the values to filter by. This way, you could ensure that only existing values are passed to the filters.
 
Please let us know if this helps.
 
Kind regards,
Vera

Please login or Register to Submit Answer