Hello,
I have a class that inherits from Telerik.WinControls.UI.Appointment. After clicking a checkbox on the edit-dialog of said appointment subclass and clicking OK, I need this single appointment to be read-only.
I have tried setting the AllowDelete and AllowEdit properties of the Appointment to false, which does the trick with regard to blocking the delete-button and preventing the edit-dialog from opening. However, I can still 'resize' and drag an appointment that is on/inside the Scheduler. Is there a way to prevent that, i.e. make this one Appointment perfectly read-only?
Thanks in advance for your answer.
I have a class that inherits from Telerik.WinControls.UI.Appointment. After clicking a checkbox on the edit-dialog of said appointment subclass and clicking OK, I need this single appointment to be read-only.
I have tried setting the AllowDelete and AllowEdit properties of the Appointment to false, which does the trick with regard to blocking the delete-button and preventing the edit-dialog from opening. However, I can still 'resize' and drag an appointment that is on/inside the Scheduler. Is there a way to prevent that, i.e. make this one Appointment perfectly read-only?
Thanks in advance for your answer.
13 Answers, 1 is accepted
0
Hi Amf,
Thank you for contacting us.
There is a way you can cancel appointments' resizing or moving. The following code snippet demonstrates which events to use in order to achieve this:
In addition, I would like to mention that in the next official release we are going to expose these events directly to the RadScheduler control. This will let you easily handle such scenarios.
I hope this is useful. Feel free to write back if you have any additional questions.
Greetings,
Ivan Todorov
the Telerik team
Thank you for contacting us.
There is a way you can cancel appointments' resizing or moving. The following code snippet demonstrates which events to use in order to achieve this:
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentMoving +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentMoving);
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(ResizeBehavior_AppointmentResizing);
this
.radScheduler1.ActiveViewChanged +=
new
EventHandler<SchedulerViewChangedEventArgs>(radScheduler1_ActiveViewChanged);
void
radScheduler1_ActiveViewChanged(
object
sender, SchedulerViewChangedEventArgs e)
{
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentMoving +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentMoving);
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(ResizeBehavior_AppointmentResizing);
}
void
ResizeBehavior_AppointmentResizing(
object
sender, AppointmentResizingEventArgs e)
{
e.Cancel =
true
;
}
void
DragDropBehavior_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel =
true
;
}
In addition, I would like to mention that in the next official release we are going to expose these events directly to the RadScheduler control. This will let you easily handle such scenarios.
I hope this is useful. Feel free to write back if you have any additional questions.
Greetings,
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.
0
AMF
Top achievements
Rank 2
answered on 27 Oct 2011, 01:07 PM
Hello Ivan,
Thank you for your answer. I have succesfully implemented your solution which prevents dragging and resizing of appointments. The only problem I still encounter is the dragging of Appointments which are larger than the schedule window.
When that happens (dragging a large appointment), the code gets to the e.Cancel line in the Moving event, but because the appointment is too large, the Scheduler window scrolls by itself, which still makes the appointment move.
Any thoughts on this? Is there a way to also cancel any scrolling events that are triggered by the Appointment moving?
Thank you for your answer. I have succesfully implemented your solution which prevents dragging and resizing of appointments. The only problem I still encounter is the dragging of Appointments which are larger than the schedule window.
When that happens (dragging a large appointment), the code gets to the e.Cancel line in the Moving event, but because the appointment is too large, the Scheduler window scrolls by itself, which still makes the appointment move.
Any thoughts on this? Is there a way to also cancel any scrolling events that are triggered by the Appointment moving?
0
AMF
Top achievements
Rank 2
answered on 27 Oct 2011, 02:45 PM
Upon closer inspection, I ran into some problems: I can still move the appointment. Any thoughts on this?
0
Hello Amf,
Thank you for writing back.
I was able to identify some cases in which the code I have provided does not work. Please try canceling the AppointmentDropping event as well as it is shown in the following snippet:
Please note that this code will not work in grouped by resource views, since the DragDropBehavior is not used for dragging between resources. I would suggest switching to the new version when it is available, since the events we are going to introduce should cover all cases.
I hope you find this useful. Should you have additional questions, do not hesitate to ask.
Greetings,
Ivan Todorov
the Telerik team
Thank you for writing back.
I was able to identify some cases in which the code I have provided does not work. Please try canceling the AppointmentDropping event as well as it is shown in the following snippet:
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentMoving +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentMoving);
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentDropping +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentDropping);
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(ResizeBehavior_AppointmentResizing);
this
.radScheduler1.ActiveViewChanged +=
new
EventHandler<SchedulerViewChangedEventArgs>(radScheduler1_ActiveViewChanged);
void
radScheduler1_ActiveViewChanged(
object
sender, SchedulerViewChangedEventArgs e)
{
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentMoving +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentMoving);
this
.radScheduler1.SchedulerElement.DragDropBehavior.AppointmentDropping +=
new
EventHandler<AppointmentMovingEventArgs>(DragDropBehavior_AppointmentDropping);
this
.radScheduler1.SchedulerElement.ResizeBehavior.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(ResizeBehavior_AppointmentResizing);
}
void
DragDropBehavior_AppointmentDropping(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel =
true
;
}
void
ResizeBehavior_AppointmentResizing(
object
sender, AppointmentResizingEventArgs e)
{
e.Cancel =
true
;
}
void
DragDropBehavior_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel =
true
;
}
Please note that this code will not work in grouped by resource views, since the DragDropBehavior is not used for dragging between resources. I would suggest switching to the new version when it is available, since the events we are going to introduce should cover all cases.
I hope you find this useful. Should you have additional questions, do not hesitate to ask.
Greetings,
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.
0
AMF
Top achievements
Rank 2
answered on 28 Oct 2011, 01:06 PM
Hello Ivan,
Thank you for your reply. We are currently working with ResourceViews, so is there a workaround to solve said problem?
Thank you for your reply. We are currently working with ResourceViews, so is there a workaround to solve said problem?
0
Hi Amf,
It appears that I have mistaken the versions and the events you need are already in the version you are using. The following code snippet demonstrates how to use them:
Please excuse me for any inconveniences caused. I hope this is useful.
If you have any additional questions, do not hesitate to ask.
Regards,
Ivan Todorov
the Telerik team
It appears that I have mistaken the versions and the events you need are already in the version you are using. The following code snippet demonstrates how to use them:
this
.radScheduler1.AppointmentMoving +=
new
EventHandler<AppointmentMovingEventArgs>(radScheduler1_AppointmentMoving);
this
.radScheduler1.AppointmentResizing +=
new
EventHandler<AppointmentResizingEventArgs>(radScheduler1_AppointmentResizing);
this
.radScheduler1.AppointmentDropping +=
new
EventHandler<AppointmentMovingEventArgs>(radScheduler1_AppointmentDropping);
void
radScheduler1_AppointmentDropping(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel =
true
;
}
void
radScheduler1_AppointmentResizing(
object
sender, AppointmentResizingEventArgs e)
{
e.Cancel =
true
;
}
void
radScheduler1_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel =
true
;
}
Please excuse me for any inconveniences caused. I hope this is useful.
If you have any additional questions, do not hesitate 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.
0
AMF
Top achievements
Rank 2
answered on 23 Nov 2011, 10:25 AM
Dear Ivan,
The events are available now, thank you for your help with that.
Now I have implemented them like this;
There is something strange about this. We have created our own inheritance of the Appointment object and fill the Allow Edit according to our needs.
Here comes the weird thing: In the Moving and Dropping events the Appointment object is not our inherited object (and thus AllowEdit is true) but when the AppointmentResizing event is fired it is our inherited object and the Appointment cannot be edited.
Am I missing something here?
The events are available now, thank you for your help with that.
Now I have implemented them like this;
void
rdSchedule_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel = (!e.Appointment.AllowEdit);
}
void
rdSchedule_AppointmentDropping(
object
sender, AppointmentMovingEventArgs e)
{
e.Cancel = (!e.Appointment.AllowEdit);
}
void
rdSchedule_AppointmentResizing(
object
sender, AppointmentResizingEventArgs e)
{
e.Cancel = (!e.Appointment.AllowEdit);
}
There is something strange about this. We have created our own inheritance of the Appointment object and fill the Allow Edit according to our needs.
Here comes the weird thing: In the Moving and Dropping events the Appointment object is not our inherited object (and thus AllowEdit is true) but when the AppointmentResizing event is fired it is our inherited object and the Appointment cannot be edited.
Am I missing something here?
0
Hi Amf,
Thank you for contacting us.
This appears to be an issue in the drag&drop functionality of RadScheduler. It has already been reported by another client and we are currently working on it. Most probably, it will be addressed in the next official release. Here is the PITS item I have created about the previously reported issue. It concerns the DataItem property, but the reason which is causing it is that the e.Appointment is actually a different object, which is your case. You can subscribe to this PITS item to track its progress.
Meanwhile, I can suggest the following workaround which uses reflection to get the original appointment:
Do not hesitate to write back if you have any further questions.
Regards,
Ivan Todorov
the Telerik team
Thank you for contacting us.
This appears to be an issue in the drag&drop functionality of RadScheduler. It has already been reported by another client and we are currently working on it. Most probably, it will be addressed in the next official release. Here is the PITS item I have created about the previously reported issue. It concerns the DataItem property, but the reason which is causing it is that the e.Appointment is actually a different object, which is your case. You can subscribe to this PITS item to track its progress.
Meanwhile, I can suggest the following workaround which uses reflection to get the original appointment:
void
radScheduler1_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
SchedulerDayViewGroupedByResourceElement dayViewElement = (
this
.radScheduler1.SchedulerElement.ViewElement
as
SchedulerDayViewGroupedByResourceElement);
SchedulerMonthViewGroupedByResourceElement monthViewElement = (
this
.radScheduler1.SchedulerElement.ViewElement
as
SchedulerMonthViewGroupedByResourceElement);
TimelineGroupingByResourcesElement timelineViewElement = (
this
.radScheduler1.SchedulerElement.ViewElement
as
TimelineGroupingByResourcesElement);
if
(dayViewElement !=
null
)
{
FieldInfo fi = dayViewElement.GetType().GetField(
"originalDraggingAppointment"
, BindingFlags.NonPublic | BindingFlags.Instance);
Appointment originalAppointment = (Appointment)fi.GetValue(dayViewElement);
}
else
if
(monthViewElement !=
null
)
{
FieldInfo fi = monthViewElement.GetType().GetField(
"originalDraggingAppointment"
, BindingFlags.NonPublic | BindingFlags.Instance);
Appointment originalAppointment = (Appointment)fi.GetValue(monthViewElement);
}
else
if
(timelineViewElement !=
null
)
{
FieldInfo fi = timelineViewElement.GetType().GetField(
"_originalDraggingAppointment"
, BindingFlags.NonPublic | BindingFlags.Instance);
Appointment originalAppointment = (Appointment)fi.GetValue(timelineViewElement);
}
}
Do not hesitate to write back if you have any further questions.
Regards,
Ivan Todorov
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Georgios
Top achievements
Rank 1
answered on 10 Jun 2013, 09:26 AM
Hi,
How would you prevent single appointment moving.
I implemented the e.Cancel but when i try to drag the appointment it "disappears" as long as i have my mousebutton down.
I should like to have "no behavior"
I can see the Issue is from 2011 and you were hinting a different implementation.
So, how should this be implemented today (2013) :)
Thnaks in advance
Georgios
How would you prevent single appointment moving.
I implemented the e.Cancel but when i try to drag the appointment it "disappears" as long as i have my mousebutton down.
I should like to have "no behavior"
I can see the Issue is from 2011 and you were hinting a different implementation.
So, how should this be implemented today (2013) :)
private void radScheduler1_AppointmentMoving(object sender, AppointmentMovingEventArgs e)
{
e.Cancel = true;
}
Thnaks in advance
Georgios
0
Hi Georgios,
The observed behavior is caused because a drag operation is initiated. You can try calling the Stop method of the drag and drop service to prevent it :
I hope this helps.
Regards,
Stefan
Telerik
The observed behavior is caused because a drag operation is initiated. You can try calling the Stop method of the drag and drop service to prevent it :
void
radScheduler1_AppointmentMoving(
object
sender, AppointmentMovingEventArgs e)
{
radScheduler1.SchedulerElement.DragDropBehavior.Stop(
true
);
e.Cancel =
true
;
}
I hope this helps.
Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
0
Georgios
Top achievements
Rank 1
answered on 13 Jun 2013, 09:00 AM
Hi,
It still "disapears" when I click on it
(It reappears when i leave the timeslot)
Regards,
Georgios
It still "disapears" when I click on it
(It reappears when i leave the timeslot)
Regards,
Georgios
0
Hello,
In this case you can try stopping the whole drag drop service:
I hope this helps.
Regards,
Stefan
Telerik
In this case you can try stopping the whole drag drop service:
radScheduler1.DragDropBehavior.Starting += DragDropBehavior_Starting;
.........
void
DragDropBehavior_Starting(
object
sender, RadServiceStartingEventArgs e)
{
e.Cancel =
true
;
}
I hope this helps.
Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
0
Georgios
Top achievements
Rank 1
answered on 19 Jun 2013, 10:45 AM
Thanks.
Seems to work :)
Georgios
Seems to work :)
Georgios