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

Add and Retrieve custom attributes on TimeSlot

1 Answer 53 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Michael Hunt
Top achievements
Rank 1
Michael Hunt asked on 07 Apr 2011, 03:05 PM
Hi,

We are using version 2010.2.826.35 of the ASP.NET for AJAX components.

Q.  I want to be able to create a custom attribute key / value on each TimeSlot in server side code, and then access that custom attribute in javascript when the time slot is clicked.  If it matters, my Scheduler will only be displayed in Monthly View.

On the server I have:
Private Sub DployRadScheduler_TimeSlotCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.TimeSlotCreatedEventArgs) Handles DployRadScheduler.TimeSlotCreated
  
    e.TimeSlot.Control.Attributes.Add("divName", "week1")
  
End Sub

I don't know how to retrieve that Attribute in javascript when the user clicks on the timeslot.  I already have the javascript function in place to handle the OnClientTimeSlotClick event, but I can't seem to get the object that contains the attribute.

Any ideas?  Or is there another way to do this?  Basically, in Month View, I just want to know what week they clicked in, within the current Scheduler (where the Scheculer is always displaying 5 weeks...).

By the way, I do see that my Attribute and Value are getting written into the source of the HTML, but I obviously don't want to try to navigate through the DOM to find the one that corresponds to the timeslot I clicked.

Thanks In Advance.

 

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 08 Apr 2011, 04:44 PM
Hi Michael,

Please, try the following -

function OnClientTimeSlotClick(sender, args) {
          if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.MonthView)
              alert(args.get_targetSlot().get_domElement().parentElement.getAttribute('divName'));
          else {              
              alert(args.get_targetSlot().get_domElement().getAttribute('divName'));
          }
      }


Kind regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Michael Hunt
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or