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

Cannot add a compositefilter programatically

4 Answers 68 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Trevor
Top achievements
Rank 1
Trevor asked on 24 May 2013, 02:58 PM
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. 

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 27 May 2013, 03:26 PM
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.

0
Trevor
Top achievements
Rank 1
answered on 28 May 2013, 02:45 PM

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




0
Dimitrina
Telerik team
answered on 29 May 2013, 01:55 PM
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.

0
Trevor
Top achievements
Rank 1
answered on 29 May 2013, 02:06 PM
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.
Tags
DataFilter
Asked by
Trevor
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Trevor
Top achievements
Rank 1
Share this question
or