gustavnavar / Grid.Blazor

Grid component with CRUD for Blazor (client-side and server-side) and ASP.NET Core MVC
GNU Lesser General Public License v2.1
698 stars 135 forks source link

GridHeaderComponent is null when I press apply button on a custom filter #384

Closed AlexeyBoyko closed 1 year ago

AlexeyBoyko commented 1 year ago

Hello, I am facing quite the same problem as described in this closed issue: https://github.com/gustavnavar/Grid.Blazor/issues/87 I am using the latest version of GridBlazor (3.5.2) and strictly follow the documented instructions. Could you please check if this old issue had resumed at some point after version 1.3.17 (where it was obviously fixed)?

AlexeyBoyko commented 1 year ago

By the way, I've made a comparison of the code introduced by this commit (https://github.com/gustavnavar/Grid.Blazor/commit/65b0caa14a4586c685ce5d6606f2a47001234555) which meant to fix the #87 issue and it seems that the current state of respective code isn't much different, except for the the variable _sequence which was eliminated since and replaced with explicit numbers. So, if it is broken then it must be for some other reason... so I wonder what could it be?

AlexeyBoyko commented 1 year ago

P.S. Just in case, my app is server-side Blazor, while in the original issue it was probably client side WASM (judging by the link to documentation provided in the question).

gustavnavar commented 1 year ago

I've tested some examples with custom filters in a server-side Blazor project. But they work fine.

By the way there is published sample here. The Customer column uses a custom filter with no errors.

Could you send a sample project including a grid that produces the error?

AlexeyBoyko commented 1 year ago

Thank you for the answer. I attach page's razor and cs files and the filter widget component. dropDownFilter.zip. If the reason for the bug is not clear from these sources, I can make a separate sample project, just let me know.

gustavnavar commented 1 year ago

You are using UserGroup as generic type parameter of the DropdownFilter class in the page Users.razor.cs:

_customFilters.Add(filterWidgetName, typeof(DropdownFilter<UserGroup>));

You must use UserViewModel as generic type parameter:

 _customFilters.Add(filterWidgetName, typeof(DropdownFilter<UserViewModel>));
gustavnavar commented 1 year ago

By the way, I recommend using a new database context and a new repository for the GridCoreServer constructor for Server Blazor projects, mainly for CRUD support.

Read from this commentary

AlexeyBoyko commented 1 year ago

Thank you kindly, it works!