Custom filter for columns with multiple items

Hello

I need to find way to customize the standard Excel filter to search for users that contain a selected role
 


As show in the image one user can have many roles 

This is the filter:

 


The problem is only single roles should be selectable in the filter, the item HR, HR Control, WFM or any other combination of roles in the same item should not exist

I need a way to customize the filter so the options look like this:

  

So if i check HR and Evaluator all users that contain HR, all users that contain Evaluator, and all users that contain both should be shown
Can you provide an example on how to do this?

Thanks

5 Replies 1 reply marked as answer

MS Manivel Sellamuthu Syncfusion Team May 26, 2021 09:39 AM UTC

Hi Gabriel, 

Greetings from Syncfusion support. 

We checked your query with provided the details and you have defined multiple values in single column value using comma separator which is showing on “Role” column. 

By default, the EJ2 Grid column only supports number, string, date, dateTime, Boolean type values, and which is not supported array type value. Please refer to the below documentation.  
  

We can show an array of values in the Grid column. But this is used only for the display purpose. We cannot perform Grid actions like Filtering, Searching, Grouping, Sorting, etc., to this column. Because the Grid can perform the actions (like sorting, grouping ,filtering) based on its dataSource value. This is the default behavior of EJ2 Grid. 

We can bind your custom dataSource to filter popup instead of default binding column(Role) data. In the provided details, Role column has multiple values with comma separator. Even if we bind the custom (Role column’s) data to filter popup Grid will consider this as string type and filtering will not work properly with your requirement. So it is not feasible to achieve your requirement. 

Please let us know, if you need further assistance. 

Regards, 
Manivel 


Marked as answer

DT Daniel Tam replied to Manivel Sellamuthu June 2, 2024 05:19 AM UTC

As of 2024-06-01, has there been any update to Syncfusion to allow this?



JS Johnson Soundararajan S Syncfusion Team June 3, 2024 10:37 AM UTC

Hi Daniel Tam,


We understand that you want to change the filter data source for the Excel filter module with a custom data source. This can be achieved by assigning a custom dataSource to the filter module in the actionBegin event for the requestType "filterbeforeopen". We have already discussed this in our knowledge base. Please refer to the link below for more information:


KB Link :   How to change the data source for checkbox filter popup in Grid? (syncfusion.com)


Please get back to us, if you need further assistance.


Regards,

Johnson Soundararajan S



DT Daniel Tam June 7, 2024 02:42 PM UTC

I was able to produce what you suggested; however, it didn't help as it seems to be comparing literal strings that match the filter checkbox.  So using the example above, when I check "HR" the filter will only return entries with only "HR".  Entries with "HR, HR Control" and  "HR, HR Control WFM" wouldn't return.

Is it possible to make it so this specific column checkboxes check for contains/includes rather than equals?



VS Vikram Sundararajan Syncfusion Team June 10, 2024 06:50 AM UTC

Hi Daniel Tam,


Based on your query, you would like to change the default operator from 'equals' to 'contains' in the Excel filter. We would like to inform you that by default, the grid filter is set to "Equals", which limits the filtering capability to exact matches only. However, the EJ2 Grid does not currently allow for the default filter type to be changed programmatically to "Contains". When using a checkbox combination with column items in the Excel filter, the predicate is generated based on the length of checked and unchecked values. Here are some examples to clarify:


  1. If there are five records in the filter dialog and you check three records to filter, the filtering is performed based on the unchecked values using the 'notequal' operator. This is because the checked values are more than the unchecked ones. Filtering based on the selected items would take more time in this case.
  2. If you select two records to filter, the filter uses the 'equal' operator because the unselected length is more than the selected length.


Therefore, providing the 'contains' operator as per your request would break the default behavior. Our Excel filter implementation is based on the Microsoft Excel filter, and thus we cannot change the operator to 'contains'.


Regards,

Vikram S


Loader.
Up arrow icon