This is a migrated thread and some comments may be shown as answers.

DatePicker format option ignored when inputing a different format from parseFormats.

7 Answers 1302 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Yann
Top achievements
Rank 1
Yann asked on 20 Aug 2012, 08:14 AM
Hi,

When a DatePicker defines both a format option and parseFormat(s) values, the control doesn't convert the date to the format specified in option.format when it is the same date.

To reproduce use the following sample script and manually modify the datepicker to be 2012/08/21 

<input id="sampleDate" name="sampleDate" value="21 Aug 2012" />       
<input id="showInputValue" type="button" />

<div id="output"></div>​​​​​​​​​​​​​​​​​ 


jQuery(
function(){
    jQuery("#sampleDate").kendoDatePicker({"format":"dd MMM yyyy","parseFormats":["yyyy/MM/dd"]});
     
        
     
     
    $("#showInputValue").click(function()
                                {
                                      $("#output").append("<div>" + $("#sampleDate").val() + "</div>");
                                });
});



Yann

7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 21 Aug 2012, 08:43 AM
Hello Yann,

 
I could not reproduce the depicted issue with the official release of Kendo UI (2012.2.710). Check this jsFiddle demo and let me know if I am missing something.

Kind 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!
0
Yann
Top achievements
Rank 1
answered on 21 Aug 2012, 08:48 AM
Hi,

I can reproduce it on your demo.
Simply type in "2012/08/21" and tab out from the control. 
The value will still be "2012/08/21" while it should be back to 21 Aug 2012 
0
Georgi Krustev
Telerik team
answered on 21 Aug 2012, 08:59 AM
Hello Yann,

 
I am not sure that we have a demo which shows the "parseFormats" functionality. Could you please point me to the demo, which you are using? I will also suggest you modify the jsBin demo, which I send you. Thus it will be easer for more me to review the case.

As a side note, the DatePicker will not change the input if it is not a valid date. In other words if the end-user enters not valid date, for instance, "not valid" or "21 Aug 2012" when the expected one is "21/08/2012", then the DatePicker will not update the input, but its value will be null.

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!
0
Yann
Top achievements
Rank 1
answered on 21 Aug 2012, 09:11 AM


I have read the description of parseFormats from the official documentation :  http://docs.kendoui.com/api/web/datepicker  

There is nothing to change to your demo. Understand that setting programatically the value will not reproduce the issue. You have to manually set a value using the keyboard as would an end user.

I am not talking about setting an incorrect value.
The demo has 
$("#sampleDate").kendoDatePicker({
    format: "dd MMM yyyy",
    parseFormats: ["yyyy/MM/dd"]
});​

To my knowledge, from the documentation it means:
the format stored in the input will be dd MMM yyyy .
The valid format that will be parsed are yyyy/MM/dd  and  dd MMM yyyy ( as the doc says :  Note that value of the format option is always used )

Now, if you manually set a value 2012/08/22  and tab out, the behavior is as intended, that is the datepicker will display and store 22 Aug 2012.
But if you set the value to be the same than the current value of the datepicker , it doesn't change the format, ie set 2012/08/21 (valid value again as it is in the format yyyy/MM/dd) when the date picker already has 21 Aug 2012, then as you tab out , the value remains 2012/08/21 instead of 21 Aug 2012.

Does it make more sense ?
0
Georgi Krustev
Telerik team
answered on 21 Aug 2012, 09:17 AM
Hello Yann,

 
Thank you for the explanation. I was able to observe the depicted issue. I confirm it as a bug, which will be addressed in the next internal build. As a gratitude for your involvement I have updated your Telerik points.

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!
0
Peter
Top achievements
Rank 1
answered on 21 Feb 2013, 11:33 AM
Hi
When will this bug fix be in official relase or how do I get a hold of it?
I have the same issue illustrated here:
http://jsfiddle.net/CXcky/

the first one works fine when putting shorter year it expands to longer year.
On the second one however, if I put a long year in, it slices it off, but it takes the first two digits so 2012 becomes 20 which then gets interpreted as 2020.
0
Georgi Krustev
Telerik team
answered on 22 Feb 2013, 12:31 PM
Hello Peter,

 
Here is a quote of the bug report opened on the same subject:


The format property is extended with the parseFormats array and thus the result will be:

["MM/dd/yy""MM/dd/yyyy"]
In this case the first format is able to parse a "10/10/2013" string and only two digits from the year part will be taken. This is expected and in order to overcome this limitation you can change the order of the formats in parseFormats array. Check the updated jsFiddle demo. 
We will further investigate the case and will try to improve current behavior of parseFormats.


I will ask you to continue our conversation in only one thread in order to avoid any duplications.
Greetings,
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!
Tags
Date/Time Pickers
Asked by
Yann
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Yann
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Share this question
or