While filtering a boolean-type column with mode set to "Checkbox", I want to be able to show both true and false checkboxes

As of now, I can only see one checkbox with "false" label, I guess this is the right behavior since none of my rows contain the value true in that column. But I want to show both true and false checkboxes, is there a way to achieve this?


ps: I'm not using the datamanager


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team September 13, 2021 04:24 PM UTC

Hi Youcef, 

  Greetings from Syncfusion support. 

  Based on your requirement you want to display both true and false options in the filter dialog box even if the rows in the grid does not contain any of the values. By default the options in the filter dialog box will be displayed based on the unique values in each fields of the dataSource. If the grid is already filtered based on an another column then the already filtered data will be stored as the `existingPredicate` which will filter the dataSource and display the filtered values in the filter dialog box. 

  You can achieve your requirement by changing the dataSource to your custom dataSource in the `actionBegin` event of the EJ2 Grid. Using this fix may cause complexities when you do filtering in multiple columns before opening the custom filter dialog box will result in the filter dialog box displaying  `No Matches Found`. We have also shared the sample for your reference. 

Please refer the code example below: 

actionBegin(args) { 
        if ( 
            args.requestType === 'filterbeforeopen' && 
            args.columnName === 'verified' 
        ) { 
           args.filterModel.options.dataSource = [ 
                { verified: true }, 
                { verified: false } 
            ]; 
        } 
    } 



Please find the attached sample and revert for more queries. 

Regards, 
Joseph I 


Loader.
Up arrow icon