I am trying to drag rows from a RadGrid containing all existing appointments to the scheduler in week-view. After dropping I want to check on collisions using your given clientside function overlapsWithAnotherAppointment.
Within the clientside RowDropping method I need to get the dragged appointment to pass it to overlapsWithAnotherAppointment. I tried getting this by using scheduler.get_appointments(). My problem now is the get_appointments() function only returns appointments which are visible within the Weekview-range.
We’re using Telerik 2011.2.915.40 using a custom SchedulerProvider in which we override the GetAppointments method. I can see this function does return all appointments, also the ones which are not visible.
What should I do so get_appointments() also returns the non-visible appointments ?
Thanks for any help,
Frank
Below are some code snippits of our implementation:
RadGrid from which rows are being dragged:
<
telerik:RadGrid
ID
=
"rgActiviteiten"
runat
=
"server"
GridLines
=
"None"
OnNeedDataSource
=
"rgActiviteiten_NeedDataSource"
Width
=
"100%"
AllowFilteringByColumn
=
"false"
ShowHeader
=
"false"
OnRowDrop
=
"rgActiviteiten_RowDrop"
DataKeyNames
=
"Activiteit_ID"
EnableViewState
=
"false"
>
<
ClientSettings
AllowRowsDragDrop
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
OnRowDropping
=
"rowDropping"
OnRowDblClick
=
"onRowDoubleClick"
/>
</
ClientSettings
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"Activiteit_ID"
ClientDataKeyNames
=
"Activiteit_ID"
AllowFilteringByColumn
=
"False"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"P_Naam"
DataField
=
"P_Naam"
HeaderText
=
"Product"
ItemStyle-Wrap
=
"false"
ItemStyle-Width
=
"335"
/>
<
telerik:GridBoundColumn
DataField
=
"Activiteit_ID"
UniqueName
=
"Activiteit_ID"
Visible
=
"true"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Scheduler to which rows will be dropped:
<
telerik:RadScheduler
ID
=
"rsSchedulerWithProvider"
runat
=
"server"
ProviderName
=
"MyDbSchedulerProvider"
Width
=
"1018px"
Height
=
"100%"
Culture
=
"nl-NL"
FirstDayOfWeek
=
"Monday"
SelectedView
=
"WeekView"
HoursPanelTimeFormat
=
"HH:mm"
CustomAttributeNames
=
"ActiviteitType_ID, Omschrijving, Activiteit_ID, Soort"
EnableRecurrenceSupport
=
"false"
EnableExactTimeRendering
=
"True"
OnClientNavigationCommand
=
"OnNavigationCommand"
AllowDelete
=
"false"
AllowEdit
=
"false"
OnAppointmentsPopulating
=
"rsSchedulerWithProvider_AppointmentsPopulating"
OnTimeSlotCreated
=
"rsSchedulerWithProvider_TimeSlotCreated"
OnResourcesPopulating
=
"rsSchedulerWithProvider_ResourcesPopulating"
OnClientAppointmentEditing
=
"OnClientAppointmentEditing"
OnClientAppointmentInserting
=
"CreateAppointment"
>
<
AppointmentTemplate
>
<
i
><%# Eval("Omschrijving")%></
i
>
</
AppointmentTemplate
>
<
WeekView
DayEndTime
=
"22:00:00"
WorkDayStartTime
=
"08:00:00"
WorkDayEndTime
=
"22:00:00"
/>
<
DayView
DayEndTime
=
"22:00:00"
WorkDayStartTime
=
"08:00:00"
WorkDayEndTime
=
"22:00:00"
/>
<
MonthView
UserSelectable
=
"false"
/>
<
TimelineView
UserSelectable
=
"false"
/>
</
telerik:RadScheduler
>
ClientSide function which handles the drop:
function rowDropping(sender, eventArgs) {
// Fired when the user drops a grid row
var htmlElement = eventArgs.get_destinationHtmlElement();
// Bij slepen van een appointment geen check
var isActiviteit = sender.get_id().indexOf('rgActiviteiten') > -1;
if (isPartOfSchedulerAppointmentArea(htmlElement)) {
// The row was dropped over the scheduler appointment area
// Find the exact time slot and save its unique index in the hidden field
var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement);
$get("TargetSlotHiddenField").value = timeSlot.get_index();
var activiteit = null;
if (isActiviteit) {
var activiteit_id = eventArgs.get_draggedItems()[0].getDataKeyValue("Activiteit_ID");
// NEXT LINE WILL GO WRONG SINCE scheduler.get_appointments() DOESN'T CONTAIN THE DRAGGED ITEM IF IT'S ORIGINAL DATE WAS OUTSIDE THE WEEKVIEW-RANGE
activiteit = scheduler.get_appointments().findByID(activiteit_id);
}
// Calculate the end time of the new appointment
// By default, new appointments span 2 rows, so we multiply the minutesPerRow property by 2
var endTime = new Date(timeSlot.get_startTime().getTime() + scheduler.get_minutesPerRow() * minute * 2);
// Check if the new appointment is overlapping with one of the existing appointments
var app = overlapsWithAnotherAppointment(activiteit, timeSlot.get_startTime(), endTime);
if ( app >= 0 ) {
eventArgs.set_cancel(true); // Cancel the event to prevent showing the insert form
}
// The HTML needs to be set in order for the postback to execute normally
eventArgs.set_destinationHtmlElement("TargetSlotHiddenField");
}
else {
// The node was dropped elsewhere on the document
eventArgs.set_cancel(true);
}
}