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

Custom attributes for appointment

1 Answer 180 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Majid
Top achievements
Rank 1
Majid asked on 21 Apr 2014, 12:43 PM

Hi,

We are testing the radScheduler for ASP.NET AJAX, we need to drag a branch name and ID from the tree view and create a visit schedule for that branch. On the nodeDropping event  we are creating a new appointment, can we add a new attribute to the appointment from the client side other than set_start, set_end and set_subject, like below we need to add "SiteId" as an attribute to the appointment.

                    var newAppointment = new Telerik.Web.UI.SchedulerAppointment();
                    newAppointment.set_start(startTime);
                    newAppointment.set_end(endTime);
                    newAppointment.set_subject(text);
                    newAppointment.set_description(siteId);
                    newAppointment.get_attributes().setAttribute("SiteId", siteId);

And in the server-side on post back, we will get all the appointments and update the database accordingly.

   foreach (Appointment a in RadScheduler1.Appointments)
        {
            string strSiteID;
            string strSubjectSiteId = a.Subject;
            DateTime startDate = a.Start;           
           string siteID = a.Attributes["SiteId"];         
        }

There is no error thrown we set the attribute at the client side, but in server side we are getting null and this attribute count is set to 0.
We have added the CustomAttributeNames="SiteId" into the markup.

Can you please guide us how we can add a custom attribute to the a Telerik.Web.UI.SchedulerAppointment.

Thank you

Regards,
Majid

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 24 Apr 2014, 08:21 AM
Hello  Majid,

Thank you for contacting Telerik Support.

I would like to clarify that when RadScheduler is populated using server-side binding only the appointment required fields could be set from the client-side: start time, end time and subject. Any additional fields such as description and custom attributes could be set from the client-side only with web service binding.

A valid workaround in this case would be to use hidden fields on the page for description and your custom attributes and store those values in them. Since the hidden fields have runat="server" set they are available on the server so you can read the appointment description and custom attribute values and assign to the appointment object on the server in AppointmentInsert event handler. This event is fired once a new appointment is about to be added to the RadScheduler control. In other words it will be fired just after calling the RadScheduler client-side object method insertAppointment and pass the appointment object.

Please find attached a sample project that implements very similar scenario.

Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
Majid
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or