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

Set Options for Multiple DatePickers using setOptions

5 Answers 287 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Jacques
Top achievements
Rank 2
Jacques asked on 27 Nov 2014, 02:02 PM
Considering the following HTML: 
<input value="" class="date-depth-year"><br />
<input value="" class="date-depth-year"><br />
<input value="" class="date-depth-year"><br />
<input value="" class="date-depth-year"><br />
<input value="" class="date-depth-year"><br />

Why does the following NOT work (to be specific, it sets the min date for the first date picker only, not all of them): 

<script>
    $(".date-depth-year").kendoDatePicker({
      start: "year",
      depth: "year"});
     
    console.log ($("[data-role=datepicker]").length);
    $("[data-role=datepicker]").data("kendoDatePicker").setOptions({
      min: "2014/12/01"
    });
     
  </script>

I know I can do this using a jQuery each loop, which definitely works, but I was interested to know why the above JS wouldn't work to set the min values for all the DatePickers on that page? 

See the following dojo:
http://dojo.telerik.com/@Jacques.vanderhoven/ebawO

Thanks,
Jacques

5 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 27 Nov 2014, 03:21 PM
Hello Jacques,

Currently Kendo UI will not loop[ through the items passed to the initialization script. And this is why we recommend the use of ID's in order to render the widgets on the page with unique identifiers. 

The workaround you already know - loop through the selection and initialize every single widget. it should not make much difference from a performance standpoint.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacques
Top achievements
Rank 2
answered on 27 Nov 2014, 03:24 PM
Hi Kiril, 

I think you might have that wrong. 

You CAN initialize all widgets like that with a single call, you just can't do something like setOptions after the widget has been initialized already.

?
0
Kiril Nikolov
Telerik team
answered on 27 Nov 2014, 03:57 PM
Hello Jacques,

Well it will work in some cases. The reason is the same - Kendo UI will not loop through the selected items and execute the function for each one of them and will set the first widget only.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jacques
Top achievements
Rank 2
answered on 27 Nov 2014, 04:00 PM
Not sure this makes much sense, but ok I'll accept that. I've marked your previous comment as the answer. 

Thanks,
Jacques
0
Kiril Nikolov
Telerik team
answered on 28 Nov 2014, 10:11 AM

Hello Jacques,


Happy to hear that you accepted the answer.

In case you have any other questions, do not hesitate to contact us.

Regards,

Kiril Nikolov

Telerik

 
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
Jacques
Top achievements
Rank 2
Answers by
Kiril Nikolov
Telerik team
Jacques
Top achievements
Rank 2
Share this question
or