Declined
Last Updated: 03 Sep 2014 07:26 by ADMIN
Kamalakannan D
Created on: 22 Jul 2014 13:07
Category: Calendar
Type: Feature Request
0
Multiple date range selection is not supported by the Telerik Calendar
We have a requirement were the users can select multiple range of dates from the Calendar control.The selected range of dates will be saved as "StartDate" and "EndDate" in the SQL database. In the Calendar control we have "RangeSelectionStartDate" and  "RangeSelectionEndDate " ,but this doesn't allow the user to select multiple range of dates .When the dates in the range are selected any other date selection deselects all dates from range selection.

It would be nice if we have the feature of selecting multiple range of dates in the upcoming release.


Regards
Karthik
1 comment
ADMIN
Radoslav
Posted on: 03 Sep 2014 07:26
You can achieve the desired functionality by suing following code snippet:
<script type="text/javascript">
    //Put your JavaScript code here.
    function dateClick(sender, args) {
        var hiddenField = $get('<%= HiddenField1.ClientID %>');
        if (hiddenField.value == "") {
            hiddenField.value = args.get_renderDay().get_date().toString();
        }
        else if (args.get_domEvent().shiftKey) {
            var viewID = args.get_renderDay().RadCalendarView.ID;
            var isDateExchanged = false;
            var startDate = new Date(hiddenField.value);
            var endDate = new Date(args.get_renderDay().get_date());

            if (startDate > endDate) {
                var tempDate = startDate;
                startDate = endDate;
                endDate = tempDate;
                isDateExchanged = true;
            }

            sender._performSelection(startDate, endDate, isDateExchanged, viewID);
            hiddenField.value = "";
        }
    }
</script>

<telerik:RadCalendar ID="RadCalendar1" runat="server" MultiViewColumns="2" RangeSelectionMode="None"
    AutoPostBack="true">
    <ClientEvents OnDateClick="dateClick" />
</telerik:RadCalendar>
<asp:HiddenField ID="HiddenField1" runat="server" />