Add and Retrieve custom attributes on TimeSlot

2 posts, 0 answers
  1. Michael Hunt
    Michael Hunt avatar
    42 posts
    Member since:
    Aug 2009

    Posted 07 Apr 2011 Link to this post

    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.

     

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 08 Apr 2011 Link to this post

    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
Back to Top