two sets of dates

4 posts, 0 answers
  1. Jim
    Jim avatar
    35 posts
    Member since:
    May 2011

    Posted 24 Sep 2014 Link to this post

    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....
  2. Jim
    Jim avatar
    35 posts
    Member since:
    May 2011

    Posted 24 Sep 2014 Link to this post

    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?
  3. Kendo UI is VS 2017 Ready
  4. Jim
    Jim avatar
    35 posts
    Member since:
    May 2011

    Posted 24 Sep 2014 in reply to Jim Link to this post

    not make it work*  (is there an edit post feature??? I don't see it)
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 26 Sep 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready