How to get TimeSlot's CssClass in OnClientTimeSlotClick event

9 posts, 1 answers
  1. Mohsin
    Mohsin avatar
    28 posts
    Member since:
    Feb 2011

    Posted 12 Apr 2011 Link to this post

    Hi Telerik Team,

    I am having problem. I have radSchedular that is populating from database. I wrote TimeSlotCreated server side event in which I set the disabled/enabled class based on my required condition (e.TimeSlot.CssClass = "Disabled";)

    In my ASPX page i wrote 

    function OnClientTimeSlotClick(sender, eventArgs)
    {
            var now = new Date();
    if (sender.get_selectedView() == Telerik.Web.UI.SchedulerViewType.WeekView) {
                if (eventArgs.get_time() < now) {
                    alert("Time slot not available");
                }
            }
    }

    this event simply shows alert if the tiemslot time is less than current time.
    I need to get the CssClass and check if CssClass is "disabled" or "enabled". So that I can show alert('Time slot not available') if the CssClass is 'disabled'.

    Prompt response is highly appreciated. 

    Regards,
    Mohsin
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 18 Apr 2011 Link to this post

    Hello Mohsin,

    Here is one possible solution:
    <script type="text/javascript">
           function OnClientTimeSlotClick(sender, args) {
               var timeSlotClassName =  args.get_targetSlot().get_domElement().className;
               alert(timeSlotClassName.match("Disabled"));
               //match() will return null if no such string is found
           }
       </script>


    Greetings,
    Peter
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Mohsin
    Mohsin avatar
    28 posts
    Member since:
    Feb 2011

    Posted 21 Apr 2011 Link to this post

    Hi Peter,

    Thanks for the help, it really works for me.
    But when I place this code under OnClientAppointmentMoveEnd event this will not giving me desired result.
    It is showing the Class of moved appointment. I want the classname of the target slot where the appointment has been moved.
    Further more i want the same scenario on OnClientAppointmentResizeEnd event.

    please tell me how to do this.

    Regards,
    Mohsin
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 Apr 2011 Link to this post

    Hello Mohsin,

    When handling OnClientAppointmentResizeEnd and OnClientAppointmentMoveEnd you can use the get_targetSlot() method.


    Kind regards,
    Peter
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Mohsin
    Mohsin avatar
    28 posts
    Member since:
    Feb 2011

    Posted 23 Apr 2011 Link to this post

    Hi Peter,

    I have placed following code in OnClientAppointmentResizeEnd and OnClientAppointmentMoveEnd event

    var slotElement = $telerik.$(eventArgs.get_targetSlot().get_domElement());
    if (slotElement.is(".Disabled") || slotElement.parent().is(".Disabled")) {
             eventArgs.set_cancel(true);
    }

    OnClientAppointmentResizeEnd work fine with above code but OnClientAppointmentMoveEnd does not. It is not getting targetSlot css, it is getting the currently selected appointment's class.

    Please suggest what do I do, is there other way to do that???

    Regards,
    Mohsin
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 28 Apr 2011 Link to this post

    Hi Mohsin,

    This might be a bug with RadScheduler. We will examine it closer and follow up if we succeed in finding a workaround.

    All the best,
    Peter
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Frank
    Frank avatar
    24 posts
    Member since:
    Nov 2010

    Posted 01 Jun 2011 Link to this post

    Any news on this one?

    This must be a bug, I also get the CssClass of the Appointment instead of the Timeslot in the OnClientAppointmentMoveEnd clientevent.
  8. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 02 Jun 2011 Link to this post

    Hello Frank,

    I am glad to let you know that this bug has been recently fixed. Please, try with the latest internal build and let me know if all is fine.


    All the best,
    Peter
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  9. Frank
    Frank avatar
    24 posts
    Member since:
    Nov 2010

    Posted 07 Jun 2011 Link to this post

    Hi Peter,

    I can confirm it's now working, great job!!

    Thanks,

    Frank
Back to Top