How to filter bool column in grid?
Hi great Support,
I have simple grid which has bool column. I am displaying it, as Checkbox

I have simple grid which has bool column. I am displaying it, as Checkbox
How can i filter this column ?

SIGN IN To post a reply.
6 Replies
1 reply marked as answer
RS
Renjith Singh Rajendran
Syncfusion Team
August 28, 2020 01:00 PM UTC
Hi Customer,
Greetings from Syncfusion support.
You can filter a bool column, by typing either true or false values in the FilterBar and click enter button. This will filter the Boolean column based on your entered true/false value. Please refer the screenshot below,
Or you can also use FilterBarTemplate feature of Grid. With this you can render a SfCheckBox in the FilterBar and you can handle the Filtering operation in Grid based on the checked/unchecked state of SfCheckBox by using the FilterByColumn in the ValueChange handler of SfCheckBox.
We have prepared a sample based on this scenario. Please download the sample from the link below,
Please refer the codes below,
public void ValueChange(ChangeEventArgs<bool> args)
{
Grid.FilterByColumn("Datum", "equal", args.Checked);
}
|
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran
Marked as answer
BL
Blazor
September 5, 2020 01:01 PM UTC
Thank you Renjith,
I made "FilterTemplate" it's working.
But i can only choose true or false, i think there must be also "null"(means all records) option but there is not.
Are there any way to achive this?
I made "FilterTemplate" it's working.
But i can only choose true or false, i think there must be also "null"(means all records) option but there is not.
Are there any way to achive this?
RS
Renjith Singh Rajendran
Syncfusion Team
September 7, 2020 07:30 AM UTC
Hi Customer,
Thanks for your update.
We suggest you to call the ClearFiltering method of Grid to clear the filtering applied in Grid. In the below code, we have rendered a button in FilterTemplate and clicking the button we have called the ClearFiltering method of Grid with the corresponding column name as parameter. Please refer and use as like the codes below,
|
<GridColumn Field=@nameof(Order.Datum) HeaderText="Datum" TextAlign="TextAlign.Center" DisplayAsCheckBox="true" Width="150">
<FilterTemplate>
<SfCheckBox TChecked="bool" ValueChange="ValueChange"></SfCheckBox>
<SfButton OnClick="OnClick">Clear</SfButton>
</FilterTemplate>
</GridColumn>
|
Documentation : https://blazor.syncfusion.com/documentation/datagrid/filtering/#filter-bar-template-with-custom-component
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran
SC
Sivakrishnan Charaparambil
March 27, 2024 10:14 AM UTC
Hello, I tried the above approach to clear the filter and it is working fine. But the template checkbox is not getting cleared. Is there any way to clear that selection?
Well, found a way to handle it!!
Bind value for the check box and set it to false on ClearFiltersAsync method. Please let me know if there is any way to take care of it without this additional piece of code.
PS
Prathap Senthil
Syncfusion Team
March 28, 2024 03:45 PM UTC
Hi
SivaKrishnan,
Based on the problem you've reported, it seems that the issue has been resolved
at your end. Using the bind-value to check or uncheck appears to be the proper
way to handle it.
Regards,
Prathap S
SIGN IN To post a reply.
- 6 Replies
- 4 Participants
- Marked answer
-
BL Blazor
- Aug 27, 2020 11:24 AM UTC
- Mar 28, 2024 03:45 PM UTC