This is a migrated thread and some comments may be shown as answers.

Persistence

4 Answers 93 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Feb 2011, 10:36 PM
Hello, 

I have the need to be able to persist and restore the state of a RadDataFilter.  I was hoping to be able to save-off and restore the FilterDescriptors collection, but unfortunately it is read-only.  So, what would be the best approach to making this happen?  Is persistence supported at all?

Thanks,
Mark


4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Feb 2011, 01:51 PM
Hi Mark,

Every collection property out there (the entire .NET Framework for example) should be read-only.

Usually, when you want to add something to a collection you add it to the collection instead of assigning a whole new reference pointing to a collection object.

Anyway, I am sure that this Code Library will get you started. What it does is save and restore FilterDescriptors by using XML.

Best wishes,
Ross
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Mark
Top achievements
Rank 1
answered on 02 Feb 2011, 04:25 PM
Hi Ross,

Thanks for your reply.  I would generally agree with your comments about collections, however, the persistence infrastructure I am trying to use expects to save off the entire collection and not simply its contents.  I can imagine a couple of workarounds, but wanted to find out what other approaches might be out there.  This library looks promising and I will look into it right away.  (FYI, the link you left was not working for me, but I found the library nonetheless.)

Thanks for your help!
Mark.
0
Rossen Hristov
Telerik team
answered on 02 Feb 2011, 04:42 PM
Hello Mark,

I simply cannot create a setter for a collection property. I will break all design principles that I am trying to follow. I am sure that this can be worked around in many different ways instead of adding a setter.

The idea of the article is simple -- each FilterDescriptor object has 4 meaningful properties. Simply read them, store them in some kind of medium of your choice and then do the opposite by reading them, re-creating the FilterDescriptor and adding it to the collection. This RadGridView example does something similar with the grid's FilterDescriptors which are the same as RadDataFilter's. It should be the same.

I hope this helps.

Regards,
Ross
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Mark
Top achievements
Rank 1
answered on 02 Feb 2011, 05:21 PM
Hi Ross,

I completely agree with your lack of desire to add a setter - I did not mean in any way to suggest that you should.  In fact, this issue has identified a flaw in our persistence infrastructure.  As it turns out the filter system that I am replacing with the RadDataFilter relied on setting a collection property - which is definitely not the best approach.

I am sure that I will be able to work around it, and the extension library you pointed me to will be a helpful resource.  If I cannot, then we will make changes to our persistence layer.  I am just glad to hear that we should be able to re-populate the collection with persisted FilterDescriptors - that should be all I really need.

Thanks again for your support,
Mark.
Tags
DataFilter
Asked by
Mark
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Mark
Top achievements
Rank 1
Share this question
or