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
close icon

How to make a custom filter on month ?

Hello,

I have a GridDateTimeColumn I want to make a custom Filter, which I can filter on the month's date.
On the filter, we see "January, February..."

How to make this, please ?


I made this, but I failed to filter the items.

 void sfDataGrid_FilterItemsPopulated(object sender, GridFilterItemsPopulatedEventArgs e)
        {
            if (e.Column.MappingName == "ShippedDate")
            {
                var itemsSource = e.ItemsSource as List<FilterElement>;
                itemsSource.Clear();
              
                itemsSource.Add(new FilterElement { ActualValue = new DateTime(2000, 1, 1), DisplayText = "January", IsSelected = true });
                itemsSource.Add(new FilterElement { ActualValue = new DateTime(2000, 2, 1), DisplayText = "February", IsSelected = true });
                itemsSource.Add(new FilterElement { ActualValue = new DateTime(2000, 3, 1), DisplayText = "March", IsSelected = true });
            }
        }


Regards

3 Replies

SR Sivakumar R Syncfusion Team October 28, 2016 04:51 PM UTC

Hi Elie, 
 
We have prepared the sample to filter based on month and year. Please find the sample from below location, 
 
Thanks, 
Sivakumar 



DJ Djooleean February 16, 2017 02:01 PM UTC

Hi guys,

when I run the sample, it doesn't work.
FilterControl's items are well formatted (ie: "March 2009") but when I filter, no more value is displayed on the grid...

So filter items are good but the filtering method doesn't work anymore (see images).
Any idea ?
thanks, Julien





JG Jai Ganesh S Syncfusion Team February 17, 2017 01:06 PM UTC

Hi Elie,  
 
The attached sample working fine and also the filtering also working as expected in our side, 
 
 
 
 
 
 
Could you please check this in your side and please share in which essential studio you have used in your application? This would be more helpful for us to analyze further. 
 
Regards, 
Jai Ganesh S 
 


Loader.
Live Chat Icon For mobile
Up arrow icon