Grid.Blazor
Grid.Blazor copied to clipboard
Multiple filters not working
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:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior Both filters should apply.
Screenshots

and after apply

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
I can not reproduce this error. I've used several filters on the demo web and no issues where detected https://gridblazor.azurewebsites.net/
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
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 what do you mean with component? I have my component:
<GridComponent T="TaskModel" Grid="@_grid"></GridComponent>
and my "_grid" has all my columns.
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.
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, ....
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)
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); ;
Here is test project you can use for reproducing the issue. https://github.com/martinscholz83/GridTest
You will see adding a second filter for the CustomerID column will fail.
Package 3.5.2 fixes this issue
That was fast :). Fix is working for me!