Detect Navigation Command prior to TimeSlotCreated

10 posts, 0 answers
  1. Dan
    Dan avatar
    32 posts
    Member since:
    Feb 2010

    Posted 07 Oct 2011 Link to this post

    In month view I need to detect if the next month or previous month arrow has been clicked. No big deal right? I just do it in the OnNavigationCommand event of RadScheduler with something like:

    if (e.Command == SchedulerNavigationCommand.NavigateToNextPeriod)

    And that works fine. The issue is that I need to set a flag in this case before the TimeSlotCreated event fires. However, in some cases, (usually the first time I click on the next month arrow) the TimeSlotCreated event fires before the OnNavigationCommand event so my flag is not set and my code bombs.

    Can anyone thing of a work around for me? Much appreciated!

    Dan
  2. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 12 Oct 2011 Link to this post

    Hi Dan,

    I inspected the issue but didn't notice anything unusual. At every single case the normal behavior is - first the TimeSlotCreated is thrown(for every single slot), after that the NavigationCommand and then another time the TimeSlotCreated so you should be careful how you reset your flag.

    Hope this will be helpful

    Regards,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Dan
    Dan avatar
    32 posts
    Member since:
    Feb 2010

    Posted 12 Oct 2011 Link to this post

    No I still find it is inconsistent and that NavigationCommand does not always fire first. I realize that TimeSlotCreated fires for each time slot and have a way to deal with that but need to guarantee that NavigationCommand fires first before the first time slot which it doesn't always do.

    Doesn't matter now though. I decided to set a hidden field on the client side with the OnClientNavigatioCommand function and this always fires before the other server side events. Thanks anyway.
  4. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 14 Oct 2011 Link to this post

    Hello Dan,

    I have inspected the throwing of the events once again in the common case but didn't observe any inconsistent behaviour. Would you be that kind to explain what is the scenario so that if there is an unsolved issue in the product, we could find it and log it for fixing.

    Greetings, Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  5. Dan
    Dan avatar
    32 posts
    Member since:
    Feb 2010

    Posted 14 Oct 2011 Link to this post

    Not sure what more I can tell you. I have placed a break point on the first line of code in each of the two events:
    RadScheduler1_NavigationCommand
    RadScheduler1_TimeSlotCreated

    When I click the next month arrow in month view, the first break is in TimeSlotCreated.

    Dan
  6. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 19 Oct 2011 Link to this post

    Hello Dan,

    I am sending you a sample project that represents a scheduler with only two timeslots. It is showing how when a navigation arrow is clicked the TimeSlotCreated event is thrown two times - one before and once after the NavigationCommand event. This is the expected behavior of the RadScheduler.  

    Hope that this will be useful.

    Regards,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Mangesh
    Mangesh avatar
    16 posts
    Member since:
    Sep 2011

    Posted 09 Sep 2012 Link to this post

    Hi,

    My query is related to this thread of Radscheduler forum. 

    If this is the expected behavior of the Radscheduler i.e., first TimeSlotCreated then NavigationCommand event and again TimeSlotCreated, It would cause performance issue to some extent. 

    TimeSlot fires for every slot in the radscheduler and already take some time to check on each timeslot basis and in this behavior it runs twice one before and one after. and hence this can lead to performance issue.

    Is there any other workaround i.e. to NavigationCommand event will fire first and then TimeSlotCreated.

    Thanks,
    Mangesh
  8. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 10 Sep 2012 Link to this post

    Hello Mangesh,

     
    Thank you for your opinion and suggestion. We have already been inspecting this possibility but unfortunately it can not be achieved because this functionality is critical for the over all behavior of RadScheduler. Please excuse us for this inconvenience. 

    You can also think using WebService binding which is our best performance scenario where TimeSlotCreated 
     is thrown only in the beginning.

    Hope this will explain the issue.

    Regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  9. Mangesh
    Mangesh avatar
    16 posts
    Member since:
    Sep 2011

    Posted 27 Nov 2012 Link to this post

    Hello Plamen,

    Is there any other way than TimeSlotCreated event to disable the the timeslot. In my application there is a difference of 5 minutes in timeslots in Radscheduler. So checking for every 5 minutes timeslots is not a good idea and also rises performance issue. What I want is I have lets say time ,For Monday , 8:00 AM to 7:00 PM. Now I wanted to apply disable css to other slots. But without using TimeSlot created. Is there any event in which I can grab all the timeslots and then one by one, I'll check it gainst the data?

    Thanks,
    Mangesh
  10. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 29 Nov 2012 Link to this post

    Hi Mangesh,

     
    One possible way to achieve this issue is with javascript as it is done in the code below:

    function pageLoad() {
                   var $ = $telerik.$;
                  var scheduler= $find('<%=RadScheduler1.ClientID%>');
                   var now = new Date();
     
                   $(".rsAllDayTable:visible td", scheduler.get_element()).each(function (i) {
     
                       var currentTimeSlot = scheduler.get_activeModel().getTimeSlotFromDomElement($(this).get(0));
     
                       $(this).css("background", " ");
     
                       if (currentTimeSlot.get_startTime() < now)
     
                           $(this).css("background", "silver");
     
                   });
     
                   $(".rsContentTable:visible td", scheduler.get_element()).each(function (i) {
     
                       var currentTimeSlot = scheduler.get_activeModel().getTimeSlotFromDomElement($(this).get(0));
     
                       $(this).css("background", " ");
     
                       if (currentTimeSlot.get_startTime() < now)
     
                           $(this).css("background", "silver");
     
                   });
               }
               
               function OnClientAppointmentInserting(sendr,args) {
     
                   if (args.get_targetSlot().get_domElement().style.background.indexOf("silver")!=-1) {
                       args.set_cancel(true);
                   }
               }
     
               function OnClientAppointmentEditing(sender,args) {
                   if (args.get_appointment().get_timeSlot().get_domElement().style.background.indexOf("silver") != -1) {
                       args.set_cancel(true);
                   }
               }


    Hope this will be helpful.

    Greetings,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top