Unplanned
Last Updated: 20 Nov 2024 07:04 by Kevin Smith
Kevin Smith
Created on: 20 Nov 2024 07:04
Category: Grid
Type: Feature Request
1
Add built-in contains filter in Grid Column Menu and persist checkbox selection

I have a Kendo Grid that follows the Set Multi-Checkbox Filtering to Use contains instead of equalTo.

- https://docs.telerik.com/kendo-ui/knowledge-base/grid-how-to-change-multi-checkbox-filter-to-contains 

This works, I am able to filter the Grid on contains condition; but after filtering and opening the column filter again, the checkbox is not selected and shows unchecked. 

I managed to fix the issue and persist the checkbox selection using the following approach:

columnMenuOpen: function(e){
            if(e.sender.dataSource.filter()){
              e.sender.dataSource.filter().filters.forEach(function(f){

                if(f.field == "OrderID" || f.field == 'ShipCountry') {
                  var checkbox = e.container.find("input[value='"+f.value+"']");
                  if(checkbox[0] && !checkbox[0].checked){
                    e.container.find("input[value='"+f.value+"']").click()  
                  }          
                }else if(f.filters[0].field == "OrderID" || f.filters[0].field == 'ShipCountry'){
                  var current = f.filters;

                  current.forEach(function(filter){
                    var checkbox2 = e.container.find("input[value='"+filter.value+"']");

                    if(checkbox2.length > 0 && !checkbox2[0].checked){
                      e.container.find("input[value='"+filter.value+"']").click()  
                    } 
                  })
                }
              })
            }
          },

Demonstrated also in the Dojo linked here - https://dojo.telerik.com/MBDcImcj.

I would like to see the functionality built-in, so I don`t need to customize the Grid behavior in its columnMenuOpen/filterMenuopen event hanldlers

Regards

0 comments