简体   繁体   中英

Selecting Multiple dates in Dojo Calendar widget

I'm currently using the dojo calendar widget like in http://dojotoolkit.org/reference-guide/dojox/widget/Calendar.html

My requirement is this:

  1. Select multiple dates to mark the selected dates as holiday and save it in DB.
  2. Push the selected dates as JSON or array
  3. Upon selecting a date, the background color needs to marked in some color to confirm it is selected.
  4. Upon deselecting, the background color needs to be changed back to white to confirm its unselected.

How could this be accomplished? Help appreciated much..

-Vinoth

有一个实验性的MultiSelectCalendar小部件

You can try this :

 <head>
    <script type="text/javascript">
        var selectedDates = {};
    </script>
 </head>
 <body class="soria">
    <style type="text/css">
        @import "dojox/widget/Calendar/Calendar.css";
    </style>
    <div dojoType="dojox.widget.Calendar">
        <script type="dojo/connect" event="onValueSelected" args="date">
            if (!selectedDates[date]) {
                selectedDates[date] = 1;
            } else {
                delete selectedDates[date];
            }
            var list = dojo.byId("selectedDates");
            dojo.attr(list, "innerHTML", "");
            for (var date in selectedDates) {
                if (selectedDates.hasOwnProperty(date)) {
                    dojo.create("li", {"innerHTML":date}, list);
                }
            }

        </script>
    </div>
    <ul id="selectedDates"></ul>
</body>

I didn't figure out how to keep the selected cells coloured yet, but it should be doable...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM