Grid.Blazor icon indicating copy to clipboard operation
Grid.Blazor copied to clipboard

Multiple filters not working

Open martinscholz83 opened this issue 2 years ago • 1 comments

Describe the bug If you create multiple filters with AND or OR, only the first filter will apply. This happens to all kind of columns, string, number, bool, ...

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Both filters should apply.

Screenshots

Bildschirmfoto 2022-04-28 um 13 06 14

and after apply

Bildschirmfoto 2022-04-28 um 13 06 47 **Desktop (please complete the following information):** - OS: macOS - Browser chrome, safari - Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

martinscholz83 avatar Apr 28 '22 11:04 martinscholz83

I can not reproduce this error. I've used several filters on the demo web and no issues where detected https://gridblazor.azurewebsites.net/

gustavnavar avatar May 05 '22 11:05 gustavnavar

I'm having the same issue. I add multiple filters to one column but when pressing 'apply' it only saves the first filter. Exactly as this issue.

Did you solve this problem/issue @martinscholz83 ?

@gustavnavar i'm setting '.Filterable(true)' to my GridClient, am i missing something else for it to work for multiple filters?

Thanks /Mattias

mattiaslundborg avatar Nov 24 '22 12:11 mattiaslundborg

We are seeing the same issue.

To resolve this, make sure that you have a matching number of columns in your component and service. That seemed to correct the issue for us.

shyftkenney avatar Jan 23 '23 12:01 shyftkenney

@shyftkenney what do you mean with component? I have my component:

<GridComponent T="TaskModel" Grid="@_grid"></GridComponent>

and my "_grid" has all my columns.

mattiaslundborg avatar Feb 14 '23 12:02 mattiaslundborg

The GridClient column definition used on the razor page and the GridServer column definition must be the same.

The samples use static column definition to use it in both GridClient and GridServer constructors.

I've tried to reproduce this error several times, but I can't. If any of you can share a project with this error I will try to fix it.

gustavnavar avatar Mar 05 '23 10:03 gustavnavar

That means if you don't configure all members of a Model in your GridClient you add to GridServer constructor this will fail?

For example

class MyModel {
    public string Member1 {get;set;}
    public string Member2 {get;set;}
    public string Member3 {get;set;}
}
...
...
Action<IGridColumnCollection<MyModel>> columns = c =>
        {
            c.Add(o => o.Member1);
            c.Add(o => o.Member2);
            
        };
...
...
var items = new List<MyModel>();
// fill items
var server = new GridServer<Setting>(items, ....

martinscholz83 avatar Mar 06 '23 14:03 martinscholz83

Are you using Blazor WebAssembly or Blazor Server?

How do you configure the GridClient object? Using the same column definition?

Action<IGridColumnCollection<MyModel>> columns = c =>
{
    c.Add(o => o.Member1);
    c.Add(o => o.Member2);        
};
...
...
var client = new GridClient<Setting>(httpClient, url, query, false, "settingsGrid", columns, locale)

gustavnavar avatar Mar 06 '23 17:03 gustavnavar

We use Blazor Server. There was an issue in my example. It should be

var server = new GridServer<MyModel>(items, ....

MyModel should just demonstrate the case not using all members. It's not the real class we use. This is how we create the client

var client = new GridClient<MyModel>(q => _service.GetSettingsGridRows(columns, q), query, false, "settingsGrid", columns).Searchable(true, false, true).Sortable().Filterable().Selectable(true, false, true).ChangePageSize(true); ;

martinscholz83 avatar Mar 06 '23 18:03 martinscholz83

Here is test project you can use for reproducing the issue. https://github.com/martinscholz83/GridTest

martinscholz83 avatar Mar 07 '23 08:03 martinscholz83

You will see adding a second filter for the CustomerID column will fail.

martinscholz83 avatar Mar 07 '23 08:03 martinscholz83

Package 3.5.2 fixes this issue

gustavnavar avatar Mar 07 '23 12:03 gustavnavar

That was fast :). Fix is working for me!

martinscholz83 avatar Mar 07 '23 12:03 martinscholz83