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

ParseFormats in Custom Template

3 Answers 80 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 08 Sep 2015, 01:28 PM

Hi

I created following example to illustrate what I am trying to achieve: http://dojo.telerik.com/IRaYU

At the top there is a simple Kendo DateTimePicker to which I have added parseFormats like so:

 

$("#datetimepicker").kendoDateTimePicker({
  format: "dd.MM.yyyy HH:mm",
  value:new Date(),
  parseFormats:[
      "dd MM yyyy HH mm",
      "dd MM yyyy HHmm",
      "dd MM yyyy HH:mm",
      "dd MM HH mm",
      "dd MM HHmm",
      "dd MM HH:mm"
  ]
});​

So it is possible to type 24 6 14 55 which translates to 24.June.2014 14:55.

I am trying to achieve the same for my custom template for the scheduler (add the same functionality).

The custom template for the scheduler looks like this:

<script id="editor" type="text/x-kendo-template">
   <h3>Edit meeting</h3>
   <p>
       <label>Title: <input name="title" /></label>
   </p>
   <p>
       <label>Start: <input data-role="datetimepicker" name="start" /></label>
   </p>
   <p>
       <label>End: <input data-role="datetimepicker" name="end" /></label>
   </p>
</script>

 

How can I add the "parseFormats" solution to the custom template?

Many thanks for any help

3 Answers, 1 is accepted

Sort by
0
Markus
Top achievements
Rank 1
answered on 08 Sep 2015, 02:34 PM

I was able to achieve adding parseFormats to the datepicker in the edit template via the function "setOptions" which I call every time the edit event is fired.

Can anyone confirm that this is the best / only option?

 Here the necessary code:

edit: function(){
    $('input[name="start"]').data('kendoDateTimePicker').setOptions({parseFormats:[
            "dd MM yyyy HH mm",
            "dd MM yyyy HHmm",
            "dd MM yyyy HH:mm",
            "dd MM HH mm",
            "dd MM HHmm",
            "dd MM HH:mm"
        ]});
  },

0
Accepted
Georgi Krustev
Telerik team
answered on 10 Sep 2015, 08:41 AM
Hello Markus,

The 'setOptions" called in the edit event handler is absolutely valid approach. If you think that the parse formats will not changed in future, then you can define them as a data-* attribute. Check the updated demo:
Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Markus
Top achievements
Rank 1
answered on 14 Sep 2015, 09:48 AM
Great thank you!
Tags
Scheduler
Asked by
Markus
Top achievements
Rank 1
Answers by
Markus
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or