We are wondering how to access the low-level appointment data (like recordset ID or internal references) in order to duplicate a selected appointment including all its settings to a new date in timeline view (v. Q2_2009).
We were looking at the exposed properties without finding something, but I guess we certainly missed something...
Edit: The selection of the appointment occurs through a contextual menu.
This has to be done server-side for technical reasons.
Anybody has an idea?
Regards,
David
6 Answers, 1 is accepted
In addition to Robert's suggestion, we have recently had a question on how to copy and paste an appointment using the context menu. Here is sample code for this functionality:
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
>
<
telerik:RadScheduler
ID
=
"RadScheduler1"
runat
=
"server"
OnAppointmentContextMenuItemClicking
=
"RadScheduler1_AppointmentContextMenuItemClicking"
OnTimeSlotContextMenuItemClicking
=
"RadScheduler1_TimeSlotContextMenuItemClicking"
>
<
AppointmentContextMenuSettings
EnableDefault
=
"true"
/>
<
AppointmentContextMenus
>
<
telerik:RadSchedulerContextMenu
ID
=
"RadSchedulerAppointmentContextMenu1"
runat
=
"server"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Copy"
Value
=
"Copy"
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadSchedulerContextMenu
>
</
AppointmentContextMenus
>
<
TimeSlotContextMenuSettings
EnableDefault
=
"true"
/>
<
TimeSlotContextMenus
>
<
telerik:RadSchedulerContextMenu
ID
=
"RadSchedulerTimeslotContextMenu1"
runat
=
"server"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Paste"
Value
=
"Paste"
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadSchedulerContextMenu
>
</
TimeSlotContextMenus
>
</
telerik:RadScheduler
>
</
telerik:RadAjaxPanel
>
protected
void
RadScheduler1_TimeSlotContextMenuItemClicking(
object
sender, TimeSlotContextMenuItemClickingEventArgs e)
{
if
(Session[
"appointment"
] !=
null
)
{
Appointment a = Session[
"appointment"
]
as
Appointment;
//The following achieves cut and paste:
//RadScheduler1.DeleteAppointment(a, true);
TimeSpan appDuration = a.Duration;
a.Start = e.TimeSlot.Start;
a.End = e.TimeSlot.Start.Add(appDuration);
RadScheduler1.InsertAppointment(a);
RadScheduler1.Rebind();
}
}
protected
void
RadScheduler1_AppointmentContextMenuItemClicking(
object
sender, AppointmentContextMenuItemClickingEventArgs e)
{
Session[
"appointment"
] = e.Appointment;
}
protected
void
Page_Init(
object
sender, EventArgs e)
{
XmlSchedulerProvider provider =
new
XmlSchedulerProvider(Server.MapPath(
"~/App_Data/Appointments.xml"
),
true
);
RadScheduler1.Provider = provider;
}
Attached is a simple demo for reference.
Kind regards,
Peter
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
I basically have the desired result I want except my calendar is not rebinding once I insert my record into the database. I have to close and rerun the page to see the new appointment. Here is my code...
Private Sub RadScheduler1_TimeSlotContextMenuItemClicking(sender As Object, e As TimeSlotContextMenuItemClickingEventArgs) Handles RadScheduler1.TimeSlotContextMenuItemClicking
If Session("appointment") IsNot Nothing Then
Dim oSched1 As Appointment = Session("appointment")
Dim oSched2 As Appointment = Nothing
Dim appDuration As TimeSpan = oSched1.Duration
oSched1.Start = e.TimeSlot.Start
oSched1.End = e.TimeSlot.Start.Add(appDuration)
Dim oScheduledShipment As New tScheduledShipment
Dim oNewShipment As New tScheduledShipment
With oScheduledShipment
.ShipmentID = oSched1.Attributes.Item("ShipmentID")
.OriginAssetID = oSched1.Attributes.Item("OriginAssetID")
.DestinationID = oSched1.Attributes.Item("DestinationID")
.Vessel = oSched1.Attributes.Item("Vessel")
.CarrierID = oSched1.Attributes.Item("CarrierID")
.ScheduledTons = oSched1.Attributes.Item("ScheduledTons")
.ScheduledShipDate = oSched1.Start
.ExpectedArrivalDate = oSched1.End
.ActionID = 1
.ActionBy = "chrisruckman"
.ActionMachine = "abc"
.ActionDate = Date.Now
End With
Using o As New CIMSLogisticsService.ScheduledShipmentsClient
oNewShipment = o.InsertScheduledShipment(oScheduledShipment)
End Using
oSched2 = New Appointment
With oNewShipment
oSched2.Attributes("ScheduledShipmentID") = .ScheduledShipmentID
oSched2.Attributes("ShipmentID") = .ShipmentID
oSched2.Attributes("OriginAssetID") = .OriginAssetID
oSched2.Attributes("DestinationID") = .DestinationID
oSched2.Attributes("Vessel") = .Vessel
oSched2.Attributes("CarrierID") = .CarrierID
oSched2.Attributes("ScheduledTons") = .ScheduledTons
oSched2.Attributes("ScheduledShipDate") = .ScheduledShipDate
oSched2.Attributes("ExpectedArrivalDate") = .ExpectedArrivalDate
oSched2.Attributes("ActionID") = .ActionID
oSched2.Attributes("ActionBy") = .ActionBy
oSched2.Attributes("ActionMachine") = .ActionMachine
oSched2.Attributes("ActionDate") = .ActionDate
End With
RadScheduler1.InsertAppointment(oSched2)
'RadScheduler1.DataSource = ScheduledShipments()
'RadScheduler1.DataBind()
RadScheduler1.Rebind()
End If
End Sub
I fixed it. My ScheduledShipments wasn't populating the datasource because it was checking to see if a session variable was being set. I simply set the session variable to nothing and called the ScheduledShipments to set the data and called the scheduler's databind methog. I removed .Rebind because it was undoing the databind()
RadScheduler1.DataSource = Nothing
Session(SCHEDULEDSHIPMENTS_DATA) = Nothing
RadScheduler1.DataSource = ScheduledShipments()
RadScheduler1.DataBind()
Thank you for shearing the approach you have chosen, in order to resolve the issue faced.
Regards,
Veselin Tsvetanov
Telerik by Progress