Search code examples
javascriptkendo-uicalendarkendo-template

How to set multiple date in the calendar with mvvm?


How to set multiple date in the calendar with mvvm.

I have my calendar :

<div id="calendar1" data-role="calendar"
          data-bind="value: Cvalue,
          dates: Csource,
          events:{change: ConChange}">
</div>

JS, view model:

Cvalue:null,
Csource:[],
Conchange:function(){
}

Csource contains:

[
 {"nome":"1"},{"data":"21/112017"},
 {"nome":"2"},{"data":"22/112017"},
 {"nome":"3"},{"data":"26/112017"},
 {"nome":"4"},{"data":"28/112017"},
 {"nome":"5"},{"data":"29/112017"}
 ]

Cain i see this dates with different color in the calendar?

and at onChange of day, i'd like to print the name of date; something like this attached image:

enter image description here


Solution

  • A plugin called multiDatesPicker will meet your requirement

    $('#mdp-demo').multiDatesPicker();
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link href="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.css" rel="stylesheet"/>
    <link href="https://code.jquery.com/ui/1.12.1/themes/pepper-grinder/jquery-ui.css" rel="stylesheet"/>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    <script src="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js"></script>
    <input id="mdp-demo">