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

Attributes.Add for client onclick event

2 Answers 282 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 01 Feb 2010, 10:58 AM
Hi All,

I'm using the scheduler to display two different types of calendar data although it comes from one stored procedure and is merged there.  I want to be able to have the user click on an appointment and then the relevant screen be displayed for that appointment type.

I am trying to use Attributes.Add to add a javascript call to one of two functions (with the relevant ID for the task).  The javascript will then open a window with the correct page in it.  The following is some abbreviated code that I cannot get to work, the scheduler itself works fine but not the click event.

Private Sub uxRadScheduler_AppointmentDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles uxRadScheduler.AppointmentDataBound  
    Dim dataRowView As System.Data.DataRowView = CType(e.Appointment.DataItem, System.Data.DataRowView)  
    If dataRowView.Item("LeaveID") IsNot System.DBNull.Value Then 
        e.Appointment.Attributes.Add("onclick""javascript:ViewLeave('" & dataRowView.Item("LeaveID").ToString() & "');")  
    Else 
        e.Appointment.Attributes.Add("onclick""javascript:ViewTask('" & dataRowView.Item("TaskID").ToString() & "');")  
    End If 
End Sub 

Any pointers?

Regards,

Jon

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 01 Feb 2010, 11:18 AM
Hello Jon,

I suggest you better handle OnClientAppointmentClick and use custom attributes to pass any additional info for the appointment. Here is an example:
<script type="text/javascript">
       function OnClientAppointmentClick(sender, eventArgs) {
             
           alert(eventArgs.get_appointment().get_attributes().getAttribute("TaskID"));
            
       }
   </script>
  
   <telerik:RadScheduler 
       ID="RadScheduler1" 
       runat="server" 
       CustomAttributeNames="TaskID"

"TaskID" should be a column name or field in your RadScheduler's data source.


Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jon
Top achievements
Rank 1
answered on 01 Feb 2010, 11:33 AM
Many thanks Peter for the amazingly quick response!

It works a treat,  I'd not seen the CustomAttributeNames flag but with that it's easy.

Best Regards,

Jon
Tags
Scheduler
Asked by
Jon
Top achievements
Rank 1
Answers by
Peter
Telerik team
Jon
Top achievements
Rank 1
Share this question
or