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

FilteringControl Prepare firing OnCollectionChanged?

2 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Bob asked on 14 Oct 2011, 02:52 PM
I am overriding the FilteringControl to remove IsContainedIn and IsNotContainedIn.  My code looks like this:

public class StringFilteringControl : FilteringControl
{
    public override void Prepare(GridViewBoundColumnBase column)
    {
        base.Prepare(column);   // <-- This fires OnCollectionChanged if actions are removed
 
        var vm = this.DataContext as FilteringViewModel;
          
        if (vm != null)
        {
            vm.AvailableActions.Remove(FilterOperator.IsContainedIn);
            vm.AvailableActions.Remove(FilterOperator.IsNotContainedIn);
        }
    }
}

The base.Prepare call is firing a collection changed event if actions are removed, and this is causing an unwanted refresh of the grid every time the filter control is opened by the user.  If I have a custom filter control, but do not remove actions, then the collection changed event is not fired, so the removal of actions seems to be the reason why the event is triggered.

I do not want the collection changed event to fire, or I need a way to know that the event was fired by the Prepare.  Is there a way to prevent this event from firing? 

Thanks for your help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 14 Oct 2011, 07:07 PM
Hello Bob,

This technique of removing filter operators has many flaws and I have to admit that.

That is why we have introduced a new feature. This is the RadGridView.FilterOperatorsLoading event which will allow you to both remove unwanted operators and define a defaultly selected operator in a proper way. You will no longer need to do these hacks with the view models once we roll out this feature. We will release a beta version of our 2011 Q3 release next week.

Hopefully, this new event will help you delete all of that code that you have and simply remove the operators that you do not want without causing any side effects at all.

We plan to release the beta early next week.

Let me know if you need a more urgent solution.

Kind regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 14 Oct 2011, 07:45 PM
That is excellent news!  I will look forward to getting the beta version next week.
Tags
GridView
Asked by
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Rossen Hristov
Telerik team
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or