Persistence

5 posts, 0 answers
  1. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 01 Feb 2011 Link to this post

    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


  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 02 Feb 2011 Link to this post

    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>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 02 Feb 2011 Link to this post

    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.
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 02 Feb 2011 Link to this post

    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>>
  6. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 02 Feb 2011 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready