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

Add custom attributes to appointments on web service bound Scheduler

1 Answer 87 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Prava kafle
Top achievements
Rank 1
Prava kafle asked on 30 Aug 2013, 02:56 PM
Hi,

I am  replacing ADO.NET data source  of Radscheduler with web service.
On  previous one, I had appointment template  that used custom attributes  inserted  on appointment data bound  event, how can I add custom attributes to  show appointment template  with this new databinding environment?

 protected void TicketsSchedule_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
      .....................
            e.Appointment.Attributes["MTaskID"] = row["MasterTaskID"].ToString();
            e.Appointment.Attributes["TaskID"] = row["SubTaskID"].ToString();
            e.Appointment.Attributes["ProjectID"] = row["ProjectID"].ToString();
.................



 <telerik:RadScheduler runat="server"  ID="RadScheduler1"    OnResourcesPopulating="RadScheduler1_ResourcesPopulating"  SelectedView="TimelineView"  EnableCustomAttributeEditing="True"   OnClientDataBound="onSchedulerDataBound"
                  OnClientAppointmentsPopulating="OnClientAppointmentsPopulating"  Width="1900px" Height="900px"    OverflowBehavior="Scroll"   OnClientResourcesPopulating="OnClientResourcesPopulating" 
                               AppointmentStyleMode="Default" >
                                <AppointmentTemplate >
                                    <div>
                                            <div id="ApptImageDiv" style="text-align:right; position:absolute; width:95%;" >
                                                 <asp:Image ID="ApptAttachmentImg" runat="server"  Width="16px" Height="17px"  CssClass="ShowAttachment"
                                                           
                                            />
                                    </div>

                                    <%#Eval("Subject") %>  
                                   </div>   
                            </AppointmentTemplate >
                            <DayView UserSelectable="True" GroupBy="TechName" GroupingDirection="Horizontal" />
                            <WeekView UserSelectable="True" GroupBy="TechName" GroupingDirection="Vertical"  />
          
Any idea?

Thanks,
Prava

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 03 Sep 2013, 02:52 PM
Hello,

Thank you for contacting Telerik Support.

Please find attached a sample project showing a RadScheduler control populated via web service. In the folder App_Code you may find the web service implementation (MyDbSchedulerProvider.cs) and specifically the method GetAppointments. An easy and convenient way of adding a custom attribute to the appointment object would be to follow the approach shown in the code snippet below:
//code behind
...
while (reader.Read())
                {
                    Appointment apt = new Appointment();
                    apt.ID = reader["ClassID"];
                    apt.Subject = Convert.ToString(reader["Subject"]);
                    apt.Start = DateTime.SpecifyKind(Convert.ToDateTime(reader["Start"]), DateTimeKind.Utc);
                    apt.End = DateTime.SpecifyKind(Convert.ToDateTime(reader["End"]), DateTimeKind.Utc);
                    apt.RecurrenceRule = Convert.ToString(reader["RecurrenceRule"]);
                    apt.RecurrenceParentID = reader["RecurrenceParentId"] == DBNull.Value ? null : reader["RecurrenceParentId"];
                    apt.Attributes.Add("customAttr", "sample value");
 
                   .....
 
                    LoadResources(apt);
                    appointments.Add(apt);
                }

That way you can access your appointment custom attribute value on the client side or use it in your appointment template.

Hope that this will be helpful.

Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Scheduler
Asked by
Prava kafle
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or