Entering date manually in a date filter in the grid

5 posts, 0 answers
  1. BishMan
    BishMan avatar
    11 posts
    Member since:
    May 2013

    Posted 18 Jun 2013 Link to this post

    Hello all,

    I have a grid with a date filter, if I pick the date from the date picker included in the filter it all works fine.

    If I enter the date as 06/17/2013 that works fine, but on the other hand if I enter the date 06/17/13 (2 digit year) I do not get results back.

    What can I do to over come this issues. 
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 20 Jun 2013 Link to this post

    Hello Jay,

    Basically the DateTime picker widget will accept two digit years if the format of the year is set to be 'yy'. To change this default format you can use the filterMenuInit event of the Grid to find these datepicker widgets and change their format.

    e.g.

    function onFilterInit(e){
        e.container.find('[data-role=datepicker]').each(function(){
             $(this).data().kendoDatePicker.options.format = 'M/d/yy'
        })
    }


    Regards,
    Petur Subev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. BishMan
    BishMan avatar
    11 posts
    Member since:
    May 2013

    Posted 20 Jun 2013 Link to this post

    Thank for your reply but based on that the user can only enter 2 digit year, I would like to support both cases where they enter either 4 digits or 2 digit year.

    Is that possible?  If it is how do I do that.
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 24 Jun 2013 Link to this post

    Hello Jay,

    The format can only be one at a time it is used for displaying and parsing:

    http://docs.kendoui.com/api/web/datepicker#configuration-format


    I am afraid there is not work-around to this.

    Kind Regards,
    Petur Subev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Bradley Fulton
    Bradley Fulton avatar
    6 posts
    Member since:
    Jan 2010

    Posted 22 Sep 2015 Link to this post

    I seem to be able to enter either two- or four-digit years.  However, I set the parseFormat to ["M/d/yy"] and format to "M/d/yyyy" but my computer's regional date is set to "M/d/yyyy".  The "d" format for dates in kendo.culture.en-us.js is "M/d/yyyy".  If you want much more detail, see

     http://bradfultonprogramming.blogspot.ca/2014/04/a-non-standard-date-format-with-aspnet.html

Back to Top
UI for ASP.NET MVC is VS 2017 Ready