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

Filtering older dates on DateTimeColumn

3 Answers 11 Views
This is a migrated thread and some comments may be shown as answers.
Spiffy Jones
Top achievements
Rank 1
Spiffy Jones asked on 22 Jun 2020, 07:14 PM

Hi,

 

I'm having a bit of an issue filtering old dates in my gridview.  By default, the datepicker select today's date.  Depending on the results and my dataset, the dates might be a couple fo years back (anywhere in between 1999 and 2020). 

 

Is there a quick way to browse through the different years on the datepicker?  At the moment, I can only switch 3 months back or forward using the arrows. 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Jun 2020, 01:18 PM

Hello, St├ęphane,  

You can change the way the dates in the GridViewDateTimeColumn are filtered. The GridViewDateTimeColumn.FilteringMode property allows you to specify whether only the date part or the time part will be considered. Setting it to GridViewTimeFilteringMode.Date will allow filtering only by Dates.

Excel-like filtering is quite useful for filtering by picking up certain years. It is just necessary to change the default filter dialog with a RadListFilterPopup as it is illustrated below and then just check the desired year (or month, or day):

        public RadForm1()
        {
            InitializeComponent();
            this.radGridView1.EnableFiltering = true;
            this.radGridView1.ShowHeaderCellButtons = true; // enable Excel-like filtering
            GridViewDateTimeColumn dateTimeColumn = this.radGridView1.Columns["OrderDate"] as GridViewDateTimeColumn;
            dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date;
            this.radGridView1.FilterPopupRequired+=radGridView1_FilterPopupRequired;
        }

        private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
        {
            if (e.Column.Name == "OrderDate")
            {
                e.FilterPopup = new RadListFilterPopup(e.Column, true);
            }
        }


I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Spiffy Jones
Top achievements
Rank 1
answered on 25 Jun 2020, 03:06 PM

Hi Dess,

 

Thanks for the answer.  The data coming from my datatable was a String, so the grid displayed it as a string as well even though it was datetime column

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Jun 2020, 11:43 AM

Hello, St├ęphane,

I hope that you find the previous reply helpful and if you have a GridViewDateTimeColumn with proper DateTime values stored in the cells, you will be able to filter easily by years via the RadListFilterPopup.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Spiffy Jones
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Spiffy Jones
Top achievements
Rank 1
Share this question
or