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

two sets of dates

3 Answers 66 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 24 Sep 2014, 11:48 PM
Hi. is it possible to send two sets of dates to date picker that will cause two different visual behaviours? for exampl: birthdays , wakes.

one would show the birthday icon and the other would show a coffin icon....

3 Answers, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 25 Sep 2014, 12:18 AM
This works :
disabledDays = [
+new Date("9/20/2014"),
+new Date("9/21/2014"),
+new Date("9/22/2014"),
];
missingDates = [
+new Date("9/12/2014"),
+new Date("9/13/2014"),
+new Date("9/14/2014"),
];

$("#kdtrFrom").kendoDatePicker({
max: new Date(),
min: new Date(year, month, 1),
format: "MMM dd, yyyy",
change: addDate,
month: {
content: '# if ($.inArray(+data.date, disabledDays) != -1) { #' +
'<div style="color:red">#= data.value #</div>' +
'# } else if ($.inArray(+data.date, missingDates) != -1) {#' +
'<div style="color:blue">#= data.value #</div>' +
'# } else { #' +
'#= data.value #' +
'# } #'
}
});

but some bizzarrrre behaviour going on, if I do:
var missingDates= etc
or remove the + signs it will complain that missingDates is undefined..... why does the "var" or the "+" make it work?
0
Jim
Top achievements
Rank 1
answered on 25 Sep 2014, 12:19 AM
not make it work*  (is there an edit post feature??? I don't see it)
0
Alexander Popov
Telerik team
answered on 26 Sep 2014, 12:24 PM
Hello Jim,

Adding a plus sign before a Date object returns its value in milliseconds. This is done in order to easily compare the dates, as simply comparing Date objects won't work as expected. For example: 
a = new Date(2014,1,1)
Sat Feb 01 2014 00:00:00 GMT+0200 (FLE Standard Time)
b = new Date(2014,1,1)
Sat Feb 01 2014 00:00:00 GMT+0200 (FLE Standard Time)
a == b
false
+a == +b
true

Using the "var" keyword changes the scope in which the variable is defined, so it is no longer accessible from the content template.

Regards,
Alexander Popov
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
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or