Good morning.
Is it possibile to prevent the user to set multiple day appointmens? I want to force the user not to extend appointments across more then one day, neither by dragging with the mouse nor by input values in the dialog window.
Thank you
Gianfranco Pesenato
Is it possibile to prevent the user to set multiple day appointmens? I want to force the user not to extend appointments across more then one day, neither by dragging with the mouse nor by input values in the dialog window.
Thank you
Gianfranco Pesenato
5 Answers, 1 is accepted
0
Hi Franco,
Thank you for writing.
You can subscribe to the AppointmentResizing event of the ResizingBehavior. Create an appointment that holds the original dates of the Appointment that is being resized. Subscribe to the AppointmentResized event of the ResizingBehavior. In this event you should change the Start and the End properties of the appointment if the day is different.
Do not hesitate to contact us in case that you have other related questions.
All the best,
Dobry Zranchev
the Telerik team
Thank you for writing.
You can subscribe to the AppointmentResizing event of the ResizingBehavior. Create an appointment that holds the original dates of the Appointment that is being resized. Subscribe to the AppointmentResized event of the ResizingBehavior. In this event you should change the Start and the End properties of the appointment if the day is different.
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(ResizeBehavior_AppointmentResizing);
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResized +=
new
EventHandler<AppointmentResizedEventArgs>(ResizeBehavior_AppointmentResized);
IEvent tempappointment =
null
;
void
ResizeBehavior_AppointmentResized(
object
sender, AppointmentResizedEventArgs e)
{
if
(e.Appointment.Start.Date != e.Appointment.End.Date)
{
e.Appointment.Start = tempappointment.Start;
e.Appointment.End = tempappointment.End;
}
}
void
ResizeBehavior_AppointmentResizing(
object
sender, AppointmentResizingEventArgs e)
{
this
.tempappointment =
new
Appointment( e.Appointment.Start, e.Appointment.End );
}
Do not hesitate to contact us in case that you have other related questions.
All the best,
Dobry Zranchev
the Telerik team
0
Franco
Top achievements
Rank 1
answered on 30 Mar 2011, 09:24 AM
Good morning.
I tried with your code, but it doesn't work, so I tried with the code below:
With this code I prevent the appointment resize and/or dropping within multiple days, but I can't prevent dropping to the next day. In other words, if I drag my appointment downward, it extends to the next day, while all the other cases are correct. How can I solve this problem?
Thank you
Gianfranco Pesenato
I tried with your code, but it doesn't work, so I tried with the code below:
Private memStartDate As Date
Private memEndDate As Date
AddHandler Me.RadScheduler1.SchedulerElement.ResizeBehavior.AppointmentResized, AddressOf ResizeBehavior_AppointmentResized
AddHandler Me.RadScheduler1.SchedulerElement.DragDropBehavior.AppointmentDropped, AddressOf DragDropBehavior_AppointmentDropped
Private Sub ResizeBehavior_AppointmentResized(ByVal sender As Object, ByVal e As AppointmentResizedEventArgs)
PreventMultipleDays(e.Appointment)
End Sub
Private Sub DragDropBehavior_AppointmentDropped(ByVal sender As Object, ByVal e As AppointmentMovedEventArgs)
PreventMultipleDays(e.Appointment)
End Sub
Private Sub RadScheduler1_AppointmentMouseDown(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.SchedulerAppointmentMouseEventArgs) Handles RadScheduler1.AppointmentMouseDown
Me.memStartDate = e.Appointment.Start
Me.memEndDate = e.Appointment.End
End Sub
Private Sub PreventMultipleDays(ByVal app As IEvent)
If app.Start.Date = app.End.Date Then Exit Sub
If (app.Start > Me.memStartDate AndAlso app.End > Me.memEndDate) OrElse (app.End > Me.memEndDate) Then
With app.Start
app.End = New Date(.Year, .Month, .Day, 23, 59, 59)
End With
ElseIf (app.Start < Me.memStartDate AndAlso app.End < Me.memEndDate) OrElse (app.Start < Me.memStartDate) Then
With app.End
app.Start = New Date(.Year, .Month, .Day, 0, 0, 0)
End With
End If
End Sub
With this code I prevent the appointment resize and/or dropping within multiple days, but I can't prevent dropping to the next day. In other words, if I drag my appointment downward, it extends to the next day, while all the other cases are correct. How can I solve this problem?
Thank you
Gianfranco Pesenato
0
Hello Franco,
Thank you for writing back.
You have to subscribe to the AppointmentMoving event of the DragDropBehavior of the SchedulerElement. In this event you should check what is the date in the cell under the mouse. You can cancel this event if the date is different than the start date.
In case that you have other related questions, feel free to write back.
Greetings,
Dobry Zranchev
the Telerik team
Thank you for writing back.
You have to subscribe to the AppointmentMoving event of the DragDropBehavior of the SchedulerElement. In this event you should check what is the date in the cell under the mouse. You can cancel this event if the date is different than the start date.
Private
Sub
DragDropBehavior_AppointmentMoving(
ByVal
sender
As
Object
,
ByVal
e
As
AppointmentMovingEventArgs)
Dim
point
As
Point =
Me
.radScheduler1.PointToClient(Cursor.Position)
Dim
table
As
DayViewAppointmentsTable = (TryCast(
Me
.radScheduler1.SchedulerElement.ViewElement, SchedulerDayViewElement)).DataAreaElement.Table
Dim
cell
As
SchedulerCellElement = SchedulerUIHelper.GetCellAtPoint(point, table.Children)
e.Cancel = e.Appointment.Start.
Date
<> cell.
Date
.
Date
End
Sub
In case that you have other related questions, feel free to write back.
Greetings,
Dobry Zranchev
the Telerik team
0
Amar
Top achievements
Rank 1
answered on 17 Oct 2011, 01:45 AM
How about writing a Javascript function like below and register with OnClientAppointmentResizing event.
function onAppointmentResizing(sender,args){
args.set_cancel(true);
}
It seems to be working. Is there going to be any problem doing this?
function onAppointmentResizing(sender,args){
args.set_cancel(true);
}
It seems to be working. Is there going to be any problem doing this?
0
Hi Amar,
Thank you for writing.
As far as I can see, the code you have posted is relevant for the in the ASP.NET AJAX version of RadScheduler, but the discussion here concerns its WinForms version. If you have any problems or questions regarding RadScheduler for ASP.NET AJAX, please post at the corresponding forum section. As to the current topic, I would like to notify you that in the next official release this functionality of RadScheduler for WinForms will be improved by exposing a variety of events that will allow you to manage the drag/drop/resize operations.
I hope this information is useful. Should you have any further questions, feel free to ask.
Regards,
Ivan Todorov
the Telerik team
Thank you for writing.
As far as I can see, the code you have posted is relevant for the in the ASP.NET AJAX version of RadScheduler, but the discussion here concerns its WinForms version. If you have any problems or questions regarding RadScheduler for ASP.NET AJAX, please post at the corresponding forum section. As to the current topic, I would like to notify you that in the next official release this functionality of RadScheduler for WinForms will be improved by exposing a variety of events that will allow you to manage the drag/drop/resize operations.
I hope this information is useful. Should you have any further questions, feel free to ask.
Regards,
Ivan Todorov
the Telerik team
Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.