Filter Template with Two Dates issue

12 posts, 0 answers
  1. Jeff Sager
    Jeff Sager avatar
    26 posts
    Member since:
    Aug 2006

    Posted 06 Apr 2009 Link to this post

    Hello,
    There seems to be a problem in the example with the Filter Template.  Go to your page http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx and select 3/27/1998 in the From DatePicker.  You should get 98 records.  Select 5/5/1998 from the To DatePicker.  You should get 826 records.  It seems to ignore the From DatePicker after you change the To DatePicker.  If you order by the Order Date ascending, you will notice that the grid has records with dates before 3/27/1998.  Is there any fix for this?  I've implemented this in a RadGrid using the exact same structure and have the same problem.  It seems like I would need to use Between instead of GreaterThanorEqualTo and LessThanOrEqualTo but I'm not sure how to reference both dates.
    Any help would be greatly appreciated.
    Thanks,
    Jeff Sager
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 09 Apr 2009 Link to this post

    Hello Jeff,

    Thank you for the report - you are absolutely right! The date range filter for the 'OrderDate' column should use between filter instead of GreaterThanOrEqualTo/LessThanOrEqualTo combination.

    I updated the corresponding RadGrid demo based on your feedback and the date range filter should honor the min/max date for both fields. Review the modified version of the implementation for more details. I updated your Telerik points for drawing our attention to this detail.

    Kind regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yen
    Yen avatar
    12 posts
    Member since:
    Jan 2009

    Posted 09 Apr 2009 Link to this post

    Hi Sebastian,

    That was very helpful.  I notice that the "Between" filter does not work for a GridDateTime column, but only for a GridBoundColumn.  I got a "The string was not recognized as a valid DateTime".  Do you have any explanation as to why that may be the case?

    Thanks,

    Yen
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 10 Apr 2009 Link to this post

    Hello Yen,

    Indeed the built-in GridDateTimeColumn do not allow between filter since the parsing mechanism of the date input (part of the date picker used for filtering) allows merely one date to be entered. To apply 'Between' filter you should either use the approach with two pickers in the filter template from the demo (OrderDate column) or built-in GridBoundColumn with textbox filter.

    Kind regards,
    Sebastian
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Yen
    Yen avatar
    12 posts
    Member since:
    Jan 2009

    Posted 11 Apr 2009 Link to this post

    Hi Sebastian & Telerik:

    As a further question regarding using the "Between" filter with dates, am I correct that the filter takes into account the time as well?  Specifically, I have the following client-side filter in a GridBoundColumn of type DateTime:

    tableView.filter("Modified""4/4/2009" + " " + "4/9/2009", Telerik.Web.UI.GridFilterFunction.Between); 

    The results include 4/9/2009 12:00AM, but not values such as 4/9/2009 2:19PM.  So when given just the date, it seems the filter assumes a time of 0:00.

    How can I specify the time in the filter?  I've tried date strings which include AM/PM time as well as 24-hour time without success.

    Any input would be greatly appreciated.

    Thanks,

    Yen

  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 14 Apr 2009 Link to this post

    Hello Yen,

    Actually it describes expected behavior. As you pointed the filtered result depends not only on the date, but the time as well. In this case, the grid can filter only the data bound to it. In other words, if the data field in the database is datetime, it is normal for the grid to compare the time values too.

    To achieve filtering based only on date and if the time is not important for further filtration, you can easily convert the datetime field into a date and return it as a date type only. The framework will convert it to a DateTime type, but in this case the time will be set to midnight.

    A project which shows how to accomplish this task is attached to this thread (see the SELECT query for details).

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Yen
    Yen avatar
    12 posts
    Member since:
    Jan 2009

    Posted 14 Apr 2009 Link to this post

    Hi Sebastian,

    Thank you for your reply.  The sample is helpful.

    I guess what I really want to know is that, since filtering is time-sensitive, would it be possible to specify a time in the filter?  That is, I don't always want to filter a datetime value at midnight.  Instead, I want to filter at the actual time.  As I mentioned, this is the current filter I have:

    tableView.filter("Modified", "4/4/2009" + " " + "4/9/2009", "Between");  

    For example, what I want to filter is from "4/4/2009 8:00am" to "4/9/2009 8:00am".  I tried to specify a time in the "from" and "to" field without any effect.

    Is there a way to achieve this?

    Thanks,

    -Yen
  9. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 15 Apr 2009 Link to this post

    Hello Yen,

    Unfortunately I do not think that such type of datetime filtering is attainable. If you succeed implementing this type of filter with custom SELECT query (returning filtered set of results based on date with time values) using the MS GridView instance, please share it with us and we will gladly help you transform it to work with our web grid.

    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Anish
    Anish avatar
    4 posts
    Member since:
    Jan 2013

    Posted 11 Aug 2013 Link to this post

    hi
    I use date picker as filter template for one of my column. It is not get filtered because of different format issue of data set coming from server and system date format settings. without converting data set format and system format is it possible to fix this.

    Thanks &Regards
    Anish
  11. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Aug 2013 Link to this post

    Hi Anish,

    I would suggest you to use DateTimeColumn and set the appropriate DataFormatString in order to apply the filtering functionality properly.

    Regards,
    Maria Ilieva
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  12. Anish
    Anish avatar
    4 posts
    Member since:
    Jan 2013

    Posted 15 Aug 2013 Link to this post

    Hi Maria,


    I changed my coloumn to GridDateTimeColumn as u mentioned but i have two issues

    1.How to set DataFormatString in aspx page from a session variable rather than using in item databound as mentioned below
     if (e.Item is GridDataItem)
                    {
                        GridColumnCollection cols = e.Item.OwnerTableView.Columns;
                        foreach (GridColumn col in cols)
                        {
                            string type = col.ColumnType.ToString();
                            if (type == "GridDateTimeColumn")
                            {
                                GridDateTimeColumn coluna = (GridDateTimeColumn)col;
                                coluna.DataFormatString = "{0:" + ShipmateUtilities.UtilityLayer.SessionEx.UserDateFormat + "}";
                            }
                        }

    2.How to set Mandatory symbols to the GridDateTimeColumn which i used in template coloumn(Refer Attachment)

    Regards
    Anish Sethu
    SBNT


  13. Milena
    Admin
    Milena avatar
    224 posts

    Posted 20 Aug 2013 Link to this post

    Hello,

    The last post of the following forum threat demonstrates a possible solution for the first problem:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/dataformatstring-for-radgrid.aspx

    Additionally, you can review this help topic.

    In regard of your second question, you can use the built-in validation of RadGrid to validate GridColumn. More information about this functionality could be found here.

    Regards,
    Milena
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017