Listening to filter changes in bound mode

4 posts, 0 answers
  1. Benjamin Piepiora
    Benjamin Piepiora avatar
    5 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2010 Link to this post

    Hello,

    I want to update a graphic control which uses the content of a RadDataGrid which is filtered by a RadDataFilter.
    Is there a way to listen to changes when the RadDataFilter Control is in bound mode? I tried to listen to FilterDescriptors.CollectionChanged and to RadDataGrid.Filtered but it doesn't seem to work.

    Regards,
    Benjamin
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 Aug 2010 Link to this post

    Hi Benjamin Piepiora,

    We tried to reproduce this behavior based on your description, but unfortunately we could not.

    Can you please open a separate support ticket and attach a sample project that demonstrates the way it does not work. We will then examine it and see what is going wrong.

    Thanks in advance. We are looking forward to hearing from you.

    All the best,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Benjamin Piepiora
    Benjamin Piepiora avatar
    5 posts
    Member since:
    Aug 2009

    Posted 31 Aug 2010 Link to this post

    Hello Ross,

    I searched a bit and found out that the error appears when you surround the RadDataFilter Control with a RadBusyIndicator. I created a support ticket (ID 343771) and attached a sample project.

    Regards,
    Benjamin
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 31 Aug 2010 Link to this post

    Hi Benjamin Piepiora,

    Let me try to explain what is going on. The BusyIndicator is not directly responsible for this behavior.

    The FilterDescriptors property of RadDataFilter is a DependencyProperty. Each time a new source is set, it is replaced. In other words, it is not the same collection instance throughout the lifetime of the control. When RadDataFilter is created, it uses an internal dummy class as its Source. This is the so called Unbound Mode. This internal dummy class provides the FilterDescriptors instance that is assigned to the property. Later on, when the real Source arrives, a new FilterDescriptors instance is assigned to this same property. So the one you are listening for is not longer there. It is a new one. Here is the flow of events:

    1. RadDataFilter is created. By default it enters Unbound Mode and creates an empty FilterDescriptors collection.
    2. You attach your event handler to this collection.
    3. The Source property is set.
    4. RadDataFilter wraps the source collection in a DataItemCollection (IQueryableCollectionView) and assigns its FilterDescriptors to the FilterDescriptors property of RadDataFilters.
    5. So basically, all the changes happen in this new collection, while you are still listening to the old one.

    Since FilterDescriptors is a DependencyProperty, you should bind to it. Then when a change occurs, you will know. You will detach the event handler from the old one and attach them to the new one. In this way, you will be sure that you are always listening to the correct collection of FilterDescriptors even is the Source changes run-time.

    I hope this helps. Let me know if it does not.

    All the best,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top