Completed
Last Updated: 10 Jan 2023 12:13 by ADMIN
Release 4.0.0 (18 Jan 2023) (R1 2023)
Aaron
Created on: 09 Jul 2020 13:39
Category: Grid
Type: Bug Report
8
Custom Filter Row Template not updated by setting the Grid State

The Custom Filter Menu in the Grid is not working as I would expect.

 

I am trying to do two things

  1. Apply filters programmatically through the Grid State
  2. Populate a custom Filter Menu with values that exist in that column

I am doing something very similar to the demo for the custom filter menu: https://demos.telerik.com/blazor-ui/grid/custom-filter-menu

I have observed that if I set a filter programatically through the grid state, those filters are applied to the grid but are not being passed through the FilterMenuTemplateContext object in the FilterMenuTemplate when I open the Filter Menu for that column.  Therefore, I cannot update my custom filter to show which values are currently being filtered on.

Is it by design that the FilterMenuTemplateContext does not contain Filters applied through the grid state or a bug?

---

ADMIN EDIT

As of Dec 2020, there is one outstanding issue - using complex filters (having a CompositeFilterDescriptor) for the FilterRow filter template gets saved in the grid state, but is not loaded as expected - the filter row uses a "regular" FilterDescriptor and cuts off additional descriptors. Thus, the context of the template does not provide all the data from the grid state and you need to extract it manually. I have attached a sample that shows one way of doing that in the StateInit handler.

The FilterMenu already provides all the data in its context and you can bind inputs in the template directly to the filter descriptors. Once the filter row can work with more complex filter descriptors as well, you would be able to create the extra descriptors (if they are not already there) and directly bind the inputs to their value, as opposed to the current approach where view-model fields are used.

---

6 comments
ADMIN
Marin Bratanov
Posted on: 24 Dec 2020 15:26

Hello Rayko,

I am pasting here our findings.

I am attaching here a sample that shows how this works fine for me so you can compare against it.

We've been reviewing this and what I can say at this point is the following:

  • I suspect that a major part of the issue is the usage of Newtonsoft.Json for the serialization. We support only the native System.Text.Json serializer. You can also try the custom converter from this sample to see if it will work better for you, yet I advise you consider using the one from my sample.
  • The sample I am attaching uses the StateInit to parse the stored state and update the view-model so that you can see the values in the inputs. Once this is done, you will be able to use the filter row in a fashion similar to the filter template - it will no longer cut off extra filter descriptors, so you could drop the view-model fields - you would be able to create the additional descriptors in the template, then directly bind to them instead of view-model fields.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Svetoslav Dimitrov
Posted on: 21 Dec 2020 23:06

Hello Rayko,

The issue you have reported will be investigated in the support ticket submitted by a colleague of yours (ticket id: 1499689). 

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Rayko
Posted on: 18 Dec 2020 16:18

Hi,

I don't know if it's really related to this topic. But I have a quite similar problem when loading GridState from Json-converted value in DB.

Custom filters are stored as CompositeFilterDescriptors. Built-in filters are FilterDescriptors. Both implement interface FilterDescriptorBase.

Serialized into Json string everything looks fine. But during deserialization Json tries to deserialize all filters to FilterDescriptorBase... sure, it's the interface.

A work-around it to define custom derialization settings to let Json know to deserialize into FilterSetting. This works for built-in filters. But custom filters (CompositeFilterDescriptor) is lost.

Please have a look at attached sample (CustomFiltering page). It's taken from Telerik's provided samples and amended to show the issue.

 

Best regards,

Rayko

 

ADMIN
Marin Bratanov
Posted on: 18 Dec 2020 07:10

Hello all,

The FilterRow has been fixed for a while (since 2.17.0), and at this point I can't say when this could be implemented for the FilterMenu, so I have changed its status to Unplanned. We are monitoring the situation and if still poses a problem for many scenarios (it did not seem to be the case a couple of months ago), we can re-prioritize this.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Marin Bratanov
Posted on: 09 Sep 2020 08:42

Hello,

Improvements for the FilterMenu in this regard can be expected through https://feedback.telerik.com/blazor/1473887-loadstate-does-not-populate-filters-data-in-gridfiltermode-filtermenu and I am keeping this open for the filter row as the situation there is more complicated, especially if we don't want a breaking change.

 

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

ADMIN
Marin Bratanov
Posted on: 10 Jul 2020 14:57

Hi Aaron,

Thank you for reaching out. Indeed, this should be investigated and remedied, the grid should let you sync the template with its state.

You can click the Follow button on this page to get email notifications about updates on this fix.

 

Regards,
Marin Bratanov
Progress Telerik