This is a migrated thread and some comments may be shown as answers.

Select Multiple Dates (More Than One Week)

1 Answer 62 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 2
Bob asked on 01 Jun 2012, 04:57 PM
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

1 Answer, 1 is accepted

Sort by
0
Bob
Top achievements
Rank 2
answered on 01 Jun 2012, 09:23 PM
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
Tags
Scheduler
Asked by
Bob
Top achievements
Rank 2
Answers by
Bob
Top achievements
Rank 2
Share this question
or