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

Use a Custom Comparer in Filter List

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.

1 Reply

SR Sabaridass Ramamoorthy Syncfusion Team 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 

Live Chat Icon For mobile
Up arrow icon