Cannot add a compositefilter programatically

5 posts, 0 answers
  1. Trevor
    Trevor avatar
    13 posts
    Member since:
    Jun 2011

    Posted 24 May 2013 Link to this post

    I need to add a nested filter to a Datafilter UI, but when I try:

    RadFilter.FilterDescriptors.Add(new CompositeFilterDescriptor());

    I get a "Cannot change ObservableCollection during a CollectionChanged or PropertyChanged event."

    When the line is executed  I am not iterating through any collection. 
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 May 2013 Link to this post

    Hello,

    May I ask you to please test with the latest internal build? Where do you try to add the nested filter? Is it on a button click or is it when an event is raised?
     

    Regards,
    Didie
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Trevor
    Trevor avatar
    13 posts
    Member since:
    Jun 2011

    Posted 28 May 2013 Link to this post


    I am intending to do this on a button click event. But I just tried it on a dispatchtimer's tick event and upgraded to 2013.1.403.1050 and had the same results. I can add regular filterdescriptors fine




  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 May 2013 Link to this post

    Hi,

    Thank you for clarifying.

    It seems that you cannot add a new CompositeFitlerDescriptor like so. You have to initialize it first.
    For example:

    private void Button1_Click(object sender, RoutedEventArgs e)
    {
        CompositeFilterDescriptor compositeDescriptor = new CompositeFilterDescriptor();
        compositeDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
        compositeDescriptor.FilterDescriptors.Add(new FilterDescriptor());
        compositeDescriptor.FilterDescriptors.Add(new FilterDescriptor());
     
        RadFilter.FilterDescriptors.Add(compositeDescriptor);
    }

    I hope this helps.
     

    Regards,
    Didie
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Trevor
    Trevor avatar
    13 posts
    Member since:
    Jun 2011

    Posted 29 May 2013 Link to this post

    Yes, thank you for the information. I arrived at the exact same conclusion and as ran the program to confirm it I got a ding on my phone that this reply had been posted =).

    It seems you cannot populate the actual filter control with empty compositefilters.  What I did was populate an observablecollection of compositefilters and filled them out there, then added the filled compositefilters to the Radfilter control.
Back to Top
DevCraft banner