DateTimeColumn will not filter correctly

2 posts, 0 answers
  1. Geoff
    Geoff avatar
    27 posts
    Member since:
    May 2012

    Posted 07 Jul Link to this post

    I have a programmatically created radgrid. One Column in the grid is a GridDateTimeColumn. I have allowed filtering on this column, but I can not get it to filter to the exact date. I initially was trying to do format so I could filter on date and time, but I would settle for just the date at this point if it got it working. The column created code is:

     

    GridDateTimeColumn bc40 = new GridDateTimeColumn();
    dg.MasterTableView.Columns.Add(bc40);
    bc40.PickerType = GridDateTimeColumnPickerType.DatePicker;
    bc40.DataField = "LaunchDate";
    bc40.HeaderText = "LaunchDate";
    bc40.UniqueName = "LaunchDate";
    bc40.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
    bc40.AutoPostBackOnFilter = true;
    bc40.DataFormatString = "{0:MM/dd/yyyy}";
    bc40.EnableTimeIndependentFiltering = true;
    bc40.FilterDateFormat = "MM/dd/yyyy";
    bc40.DataType = typeof(System.DateTime);
    bc40.Display = true;

     

    I have try muliple variations of FormatString, FilterFormats, Disabled TimeIndepence with no such luck. I though it may be looking directly at the grid's format, so I have also added this to my ItemDataBound event:

     

    DateTime launchDateTime = DateTime.Parse(item["LaunchDate"].Text.ToString());
    string formattedDateTime = String.Format("{0:MM/dd/yyyy}", launchDateTime);
    item["LaunchDate"].Text = formattedDateTime;

     

    The date on the grid shows up in the format of 01/01/2016. The format in the filter shows up as 01/01/2016. But when the filter of "Equal To" is set, I don't retrieve any records.

     

    This filter is a requirement for my application to work properly. Any help would be greatly appreciated.

     

  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 12 Jul Link to this post

    Hi Geoff,

    Please create the grid structure during Page_Init event handler and add the properties before the grdContingentDevelopment.MasterTableView.Columns.Add(TotalColumn) line:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/defining-structure/creating-a-radgrid-programmatically#creating-a-radgrid-on-page_init

    I hope this will prove helpful.


    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top