Filtering older dates on DateTimeColumn

4 posts, 0 answers
  1. Spiffy Jones
    Spiffy Jones avatar
    3 posts
    Member since:
    Oct 2006

    Posted 22 Jun Link to this post

    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. 

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3988 posts

    Posted 23 Jun Link to this post

    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.
  3. Spiffy Jones
    Spiffy Jones avatar
    3 posts
    Member since:
    Oct 2006

    Posted 25 Jun in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3988 posts

    Posted 26 Jun Link to this post

    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.
Back to Top