Select Multiple Dates (More Than One Week)

2 posts, 0 answers
  1. Bob
    Bob avatar
    6 posts
    Member since:
    Nov 2011

    Posted 01 Jun 2012 Link to this post

    When the RadScheduler is in MonthView, I want to be able to highlight multiple days that span more than one week.  We have implemented a custom context menu when the user right-clicks in the highlighted area, that adds an all-day appointment for each day in the highlighted range once they have selected an option.  The problem is we can only highlight a week at a time (on the same row) to get this to work.  Once we span multiple rows, the date range does not work.

    Is there some property that lets us achieve this?

    function OnClientTimeSlotClick(sender, eventArgs) {
        if (!sender.get_readOnly()) {
            var startTime = sender._rowSelectionState.rowSelectionStartSlot._startTime;
            var endTime = sender._rowSelectionState.rowSelectionEndSlot._startTime;
            var dateStart = window.document.getElementById("<%= DateStart.ClientID %>");
            var dateEnd = window.document.getElementById("<%= DateEnd.ClientID %>");
            dateStart.value = startTime.toDateString();
            dateEnd.value = endTime.toDateString();
        }
    }

    Protected Sub RadScheduler_TimeSlotContextMenuItemClicking(ByVal sender As Object, ByVal e As TimeSlotContextMenuItemClickingEventArgs)
        Dim scheduler As RadScheduler = DirectCast(sender, RadScheduler)
        Dim MyDateStart As Date
        Dim MyDateEnd As Date
        If Me.DateStart.Value <> "" Then
            'date range set
            MyDateStart = CDate(Me.DateStart.Value)
            MyDateEnd = CDate(Me.DateEnd.Value).AddDays(1)
            If Not ((e.TimeSlot.Start >= MyDateStart) And (e.TimeSlot.End <= MyDateEnd)) Then
                'single cell is NOT within highlighted range; reset dates
                MyDateStart = e.TimeSlot.Start
                MyDateEnd = e.TimeSlot.End
            End If
        Else
            'date range NOT set
            MyDateStart = e.TimeSlot.Start
            MyDateEnd = e.TimeSlot.End
        End If
        For Each appt As Appointment In scheduler.Appointments.GetAppointmentsInRange(MyDateStart, MyDateEnd)
            'delete appointment(s)
            Appointments.Remove(FindById(appt.ID))
        Next
        AddAppointment(scheduler, MyDateStart, MyDateEnd, e.MenuItem.Text, e.MenuItem.Value)
    End Sub
  2. Bob
    Bob avatar
    6 posts
    Member since:
    Nov 2011

    Posted 01 Jun 2012 Link to this post

    function OnClientTimeSlotContextMenu(sender, eventArgs) {
        if (!sender.get_readOnly()) {
            var startTime = sender._rowSelectionState.rowSelectionStartSlot._startTime;
            var endTime = sender._rowSelectionState.rowSelectionEndSlot._startTime;
            var dateStart = window.document.getElementById("<%= DateStart.ClientID %>");
            var dateEnd = window.document.getElementById("<%= DateEnd.ClientID %>");
            dateStart.value = startTime.toDateString();
            dateEnd.value = endTime.toDateString();
        }
    }

    It was simple to change.  I was just using the wrong event. 

    Instead of using OnClientTimeSlotClick, use OnClientTimeSlotContextMenu
Back to Top