Grid filter for bool?

1 Answer 1095 Views
Grid
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 21 May 2021, 10:35 AM

I have a field in a grid, which is a nullable Boolean. However, the filter option for this field, shown by the grid just has options for true and false.

This is obviously incorrect for a nullable Boolean, which should also show a filter option for null.

How can I rectify this?

I'm using version v2021.1.119 

Thanks

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 26 May 2021, 08:53 AM

Hi Andrew,

 

Thank you for writing to us.

You can achieve this requirement in the same fashion as the Discontinued column demonstrated here:
https://demos.telerik.com/kendo-ui/grid/filter-multi-checkboxes

 

Regards,
Eyup
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

AP
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 28 May 2021, 08:55 AM

Thanks for your response, but this link is not for the MVC version. My grid is defined user razor syntax, not JavaScript. The MVC demo just shows the multi option being enabled. This also shows a select all option, and bases the selection on values in the data -which I do not want. How can I just have a true / false / empty selection (in MVC razor syntax)?
Eyup
Telerik team
commented on 01 Jun 2021, 06:48 PM

Sorry, here is the MVC link for the same:
https://demos.telerik.com/aspnet-mvc/grid/filter-multi-checkboxes

If the issue remains, could you open a formal support thread and send us a basic isolated runnable version of your project? Then, we will modify it to achieve true/false/empty selection and send it to you accordingly.

AP
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 21 Jun 2021, 02:02 PM

Sorry for the delayed response, I have had a chance to look at this, and the multi-select option is not what I want. It only seems to work when the grid is filtered down to a small number of records, otherwise a json serialisation / deserialisation error is thrown due to the returned string being too long. I do not want a filter option to cause a re-query of the data. I just want the filter options of true , false or null. The fact this isn't the default for fields of bool? is a bug in my opinion. How can I achieve this filter option?
Eyup
Telerik team
commented on 24 Jun 2021, 01:57 PM

In this case, I think the best option would be to use a DropDownList:
https://docs.telerik.com/kendo-ui/knowledge-base/grid-boolean-dropdownlist-filter

Here is the actual sample:
https://dojo.telerik.com/oXarUVIz

Let me know what you think about that.

AP
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 25 Jun 2021, 10:17 AM

Thanks for your response, however I needed an option to filter for the nulls, not just 'All'. I did try adding a drop-down filter, but it won't work for nulls. In the end I mapped the field to a string in the view and added a custom drop-down filter.
Eyup
Telerik team
commented on 28 Jun 2021, 08:44 AM

I am glad that you've managed to find a way how to achieve this. And thank you for sharing your approach with our community.
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Eyup
Telerik team
Share this question
or