Setting min value on datepicker initialisation messes with the default format string?

6 posts, 0 answers
  1. Duane
    Duane avatar
    8 posts
    Member since:
    Jul 2011

    Posted 31 Mar 2012 Link to this post

    I've setup a kendo datepicker with kendo mvvm binding as detailed below, and if I enable the "min" value during the datepicker initialisation, the bound date becomes of the format: "Sat Mar 31 2012 00:00:00 GMT+1000 (E. Australia Standard Time)", whereas if I remove the setting of the "Min" value, the format becomes "2012/03/31" which is what I expect it to do with the "min" value set.  

    Is this a bug in kendo? Tested in latest chrome browser with kendo release 2012.1.322.

    view code:
    <div id="container">
    <input id="dateFrom" class="datePicker" data-role="datepicker" data-bind="value: startDate"/>
    </div>

    javascript:
    $(document).ready(function() {
    var viewModel = kendo.observable({
    startDate: new Date("2012/03/31") });
    kendo.bind($("#container"), viewModel);


    $(".datePicker").width(182).kendoDatePicker(
    {
                                    format: "yyyy/MM/dd",
    min: new Date() // this line right here causing the format to change of the databound value
    });
    });
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 02 Apr 2012 Link to this post

    Hello Duane,

    Currently, when the value of the DatePicker widget is set to value out of range, the string representation of the value is displayed in the input element and the value of the widget is null. This jsFiddle shows the correct behavior. Could you please share why you need to set a value which is out of range and what should be desired behavior?

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Duane
    Duane avatar
    8 posts
    Member since:
    Jul 2011

    Posted 02 Apr 2012 Link to this post

    I don't actually need to set the value to something that is outside of the range in this case, it turns out that I misunderstood how javascript dates were working in this case (i.e. new Date() having both date and time of initialisation, so it was actually ahead of the start of the current day, and in effect setting it to be that value makes that current day unselectable in the datepicker).

    I think when I saw in the demo code the datepicker's "value" being set to "new Date()" I thought I could do the same for min / max as needed, but evidently this is not the case.

    Thanks for clearing that up for me.
  5. Borys
    Borys avatar
    2 posts
    Member since:
    Jul 2015

    Posted 08 Oct in reply to Georgi Krustev Link to this post

    Hello, I have similar issue. 

    We need to set min for date picker for the current date, but start date can be set to the older date.

    Datepicker displays start date as a string. Is there way to work around this behavior?. 

     

  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 13 Oct Link to this post

    Hello Borys,

    The DatePicker will not display the value properly formatted if the passed value is not recognizable. This means that the string value cannot be parsed properly using the default parseFormats option:

    http://docs.telerik.com/kendo-ui/api/javascript/ui/datepicker#configuration-parseFormats

    Please define the proper parse formats to avoid the described behavior. If the problem still persists, could you provide a repro Dojo demo? This will help us to get a understanding of the case and provide up-to-the-point solution.

    Regards,
    Georgi Krustev
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  7. Borys
    Borys avatar
    2 posts
    Member since:
    Jul 2015

    Posted 13 Oct in reply to Georgi Krustev Link to this post

    I found answer in the other forum's post. Datepicker does not format start value properly if the start value is out of the range ( in my case before the "min" property). One of workarounds was to set/update min date at the open/navigate event.
    Which is kind of annoying. 

     

Back to Top
Kendo UI is VS 2017 Ready