Deserialize CompositeFilterDescriptor

1 Answer 118 Views
Filter
John
Top achievements
Rank 1
Iron
John asked on 11 Jul 2022, 04:58 PM

I'm trying to save the CompositeFilterDescriptor.

If I do the following:

var serializedFilter = JsonSerializer.Serialize(FilterValue);
var deserializedFilter = JsonSerializer.Deserialize<CompositeFilterDescriptor>(serializedFilter);

The deserializedFilter FilterDescriptor.MemberType is null and if used causes the the display of the filters to throw an exception.

Note that the filters are part of a user preferences class that is serialized as a whole. So is there a proper way to serialize/deserialize?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Jul 2022, 05:54 AM

Hi John,

MemberType is a Type and falls under a known limitation. You can either populate the MemberTypes manually after deserialization, or implement some more elaborate workaround that will automate the process for you.

Regards,
Dimo
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/.

Víctor
Top achievements
Rank 1
Iron
Iron
Iron
commented on 09 Mar 2023, 05:03 PM

I would also like to deserialize it. Do you have an example?

I want to create filter pressets, I don't understend how I cold do that if I can not deserialize the filters. 

I see there is a .ToJson() method, why not just add a FromJson method?

Dimo
Telerik team
commented on 09 Mar 2023, 05:16 PM

@Victor - you can serialize and deserialize filters like any other object.

The only thing to do after deserialization is to set the MemberType property of each FilterDescriptor manually. Since you know the Member property values, you should be able to find out and set the correct MemberType as well.

Tags
Filter
Asked by
John
Top achievements
Rank 1
Iron
Answers by
Dimo
Telerik team
Share this question
or