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

Pass through Custom Attribute to Javascript

2 Answers 92 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Paul Chambers
Top achievements
Rank 1
Paul Chambers asked on 10 Dec 2008, 10:47 PM
Hello

I'd like to pass one of my databound custom attributes from an Appointment item to a Javascript function on the click event.

Is this possible?

I've correctly bound the datasource with the custom attibutes and exposed them in the Appointment template.
As for the click event, being a novice at JS, I've tried a few times but may be getting muddled up with the syntax...

ie. I'd like to achieve:
After clicking Appointment (x), execute Javascript function MyClickEvent (attributeValue), where x.AttributeValue is evaluated from the attribute "resource_name" in the Appointment Template:

The Code: variations on:

 

 

<AppointmentTemplate>

 

 

 

    <div class= <%# Eval("Attributes['ClassTag']") %>

 

 

 

        onclick="MyClickEvent("<%# Eval("Attributes['resource_name']") %>")" >

 

 

 

    </div>

 

 

 

</AppointmentTemplate>

Any guidance appreciated.
Cheers
Paul

 

2 Answers, 1 is accepted

Sort by
0
Paul Chambers
Top achievements
Rank 1
answered on 11 Dec 2008, 04:20 AM
Think I've found the answer:

a)    Specify the CustomeAttributeNames at the RadScheduler level. I was looking at it from the angle of wiring up a click event within a control within an Appointment Template....

b)    Specify the function in the OnClientAppointmentClick event, eg.
            OnClientAppointmentClick = CreateSchedulerDock

c)    Within the function, use something like the following 

var resourceName = eventArgs.get_appointment().get_attributes().getAttribute("resource_name");

Cheers
Paul

0
Peter
Telerik team
answered on 11 Dec 2008, 03:53 PM

There you go! :) Here is a help topic you can refer to in general:
http://www.telerik.com/help/aspnet-ajax/client-side-objects-schedulerappointment.html



Kind regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Scheduler
Asked by
Paul Chambers
Top achievements
Rank 1
Answers by
Paul Chambers
Top achievements
Rank 1
Peter
Telerik team
Share this question
or