Change Filter on Switch Change

Hi,
I've a datagrid with columns allowing to be filtered.
i have a switch that i would like it that on "on" Value to change filter on a specified column and on "off" value clear the filters.

I've done this but does'nt work : (show_MP is the property binded to the radzenswitch and onMPChange the method of the Change property of the radzenswitch)

  public void onMPChange()
    {
        if(show_MP)
        {
            SuiviExpeditionGrid.ColumnsCollection.First(c => c.Property == "Maildestinataire").ClearFilters();

        }
        else
        {
            SuiviExpeditionGrid.ColumnsCollection.First(c => c.Property == "Maildestinataire").FilterOperator = FilterOperator.IsNotEmpty;

        }
        
        SuiviExpeditionGrid.Reload();

Here is what I've tried and it worked for me:

hi @enchev,

Here is what i've done but it doesn't work :
public async Task onMPChange()
{
if(show_MP)
{
SuiviExpeditionGrid.ColumnsCollection.First(c => c.Property == "Maildestinataire").ClearFilters();
await SuiviExpeditionGrid.Reload();

        }
        else
        {

            SuiviExpeditionGrid.ColumnsCollection.First(c => c.Property == "Maildestinataire").FilterOperator = FilterOperator.IsNotEmpty;
            await SuiviExpeditionGrid.Reload();
        }

}

if i do the filter manually it work and filters the emptyline and the the clear from program works, but the part where i apply the IsNotEmpty seems not to work .

Regards

You can use our source code to debug your case to see what and why is not working.

HI,

How can i do That ?

By attaching Radzen.Blazor project to your solution and use it as project reference in Visual Studio instead NuGet package:

Not sure of what i've debug but It seems that the isnotempty or isempty is not correctly applied to my datas...
May be a bas convert beetwen empty string in a GRPC property and blazor / radzen ...
I've switched all may Empty values to null and the isnotempty to isnotnull and it works .
Not sure that's the solution but for this case it do the work.

IsEmpty and IsNotEmpty will not work if you have values with whitespaces - they look empty however they are not.

No i have String.Empty Values or "" .
When i look my datas in the debugger they are marked as "" but the operator won't filter them...
I had to put null values for my code to work.
I've also test with Contains operator and the code is working . I really think there's a bug in the code somewhere for empty values.

And you can prove this if you debug your case as I suggested you.

NO because i don't know how to check this. i've put breakpoints in the code on datagridcolumns when the filter is applied i see the filter saying something like np(Maildestinataire) !="""" and then it says statehaschanged but i can't track more i don't know how to do ?

Well, not sure what else we can do to help you. We provide free components with full source code, we are trying to replicate your scenario again for free and we are answering your questions (for free). I'm afraid that we cannot do anything else.