We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Use a Custom Comparer in Filter List

Thread ID:





144437 May 6,2019 03:43 PM UTC May 7,2019 11:06 AM UTC WPF 1
Tags: PivotGridControl
Carlos Fernando Consigli
Asked On May 6, 2019 03:43 PM UTC

Hi, I'm working with PivotGridControl. I'm already using a custom comparer for PivotItems that works ok.
Is there a way to apply this same order to the elements listed in each filter? In general it is more intuitive to have the elements in the same order both in the grid itself and in the filter list.
Thanks in advance.

Sabaridass Ramamoorthy [Syncfusion]
Replied On May 7, 2019 11:06 AM UTC

Hi Carlos, 
If you are using your custom comparer for PivotItems, all the items of filter popup are displayed in given order. If you are adding the pivot items into filters dynamically, your custom comparer will be applied for filter items also. At the same time, if you would like to add the filters programmatically and need to set the comparer for them, then you can achieve this by using Comparer property available in FilterItemsCollection class. Please refer to the following code example. 
public MainWindow() 
            pivotGrid1.PivotColumns[0].Comparer = new DayComparer(); 
            pivotGrid1.Loaded += PivotGrid1_Loaded; 
        private void Filters_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
            var fItem = e.NewItems[0] as FilterItemsCollection; 
            if (fItem != null && fItem.Name == "Week") 
                fItem.Comparer = new WeekComparer(); 
        private void PivotGrid1_Loaded(object sender, RoutedEventArgs e) 
            pivotGrid1.GroupingBar.Filters.CollectionChanged += Filters_CollectionChanged;            
We have prepared a simple sample to achieve your requirement and it can be downloaded from below location. 
Sabaridass R 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon