Getting end time of slot

15 posts, 0 answers
  1. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 25 Nov 2010 Link to this post

    Hi,

    I am trying to use the new feature in 2010.3 where a slot is marked, then using a context menu to add a new event.

    Everything appears to work OK, except I am having trouble getting the slot end time.

    At the moment adding an appointment calls javascript to perform a hand coded insert using RadWindow:
    function AppointmentInserting(sender, eventArgs) {
        stopTimer();
        var d = eventArgs.get_startTime();
        var eventDate = displayDate(d);
        var timeSlot = eventArgs.get_targetSlot();
        var start = formatDate(eventArgs.get_startTime());
        var duration = timeSlot.get_durationInMinutes();
        var end = formatDate(timeSlot.get_endTime());
        var isAllDay = eventArgs.get_isAllDay();
        var ow = window.radopen("EditEvent.aspx?Mode=Insert&Start=" + start + "&IsAllDay=" + isAllDay, "AdvancedForm");
        ow.set_title(eventDate);
        ow.Maximize();
        eventArgs.set_cancel(true);
        return false;
    }

    get_startTime() works OK (and always has), but attempts to get the endTime always return the default end time, and get_duration seems to return a null. 

    Any help on the correct code would be greatly appreciated.

    David Penny
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 30 Nov 2010 Link to this post

    Hello David Penny,

    Because, there are many slots selected, we decided to provide the duration of the selectedArea. Having the startTime and the duration is sufficient to get the end time of the selected area.
    To get the duration you can use get_durationOfSelectedArea method of RadScheduler's client-side object representation.

    I hope this solves it for you!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jumpstart 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Julio Morel
    Julio Morel avatar
    7 posts
    Member since:
    Oct 2009

    Posted 02 Dec 2010 Link to this post

    Hi, I'm trying to get the duration, but it doesn't work in my test. Can you provide  me some sample code?
    get_durationOfSelectedArea()
  5. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 07 Dec 2010 Link to this post

    Hello Julio Morel,

    Could, you, please, further explain what do you mean by "I'm trying to get the duration, but it doesn't work in my test"? Could you post the code of your "test", please?


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  6. Julio Morel
    Julio Morel avatar
    7 posts
    Member since:
    Oct 2009

    Posted 07 Dec 2010 Link to this post

    Hi,
    my code is this:

     

     

    function OnClientTimeSlotClick(sender, eventArgs)

     

    {

     

     

    //alert(eventArgs.get_time());

     

     

     

    //var duration = timeSlot.get_durationInMinutes();

     

     

     

    // var timesel = get_durationOfSelectedArea()

     

     

     

    //var ssss = eventArgs.get_durationBetweenTimeSlots()

     

     

     

    var startTime = eventArgs.get_targetSlot().get_startTime();

     

     

     

    var endTime = new Date(startTime);

     

    endTime.setMinutes(endTime.getMinutes() + 45);

     

     

     

    var wnd = window.radopen("BPacientes.aspx?sh=" + eventArgs.get_time(), null);

     

     

     

    //eventArgs.get_durationOfSelectedArea()

     

    wnd.setSize(860, 600);

     

     

    return false;

     

    }


    I actually can get the time of the selected slot with: eventArgs.get_time(), but I'm not getting the slot end time. I tried this: get_durationOfSelectedArea, but maybe I'm implementing it wrong.
  7. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 07 Dec 2010 Link to this post

    Julio,

    It seems the syntax is:

    var

     

     

    duration = sender.get_durationOfSelectedArea();

    The method works against the RadScheduler as a whole rather than a timeslot.  I have tried the above and it seems to return the duration of the timelot in milliseconds.

    Dave Penny

     

  8. Julio Morel
    Julio Morel avatar
    7 posts
    Member since:
    Oct 2009

    Posted 07 Dec 2010 Link to this post

    Sorry, but I'm still getting this error.
    Image attached.
  9. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 07 Dec 2010 Link to this post

    Nikolay,

    I can use get_durationOfSelectedArea OK, but have another problem.  Once a block of timeslots has been highlighted, when I right click and select my menu option to Add a new Appointment, the StartTime that is returned is now always the start time of the time slot I right clicked on, not the start time of all highlighted time slots.

    Is there any way, short of telling my clients to always right click on the first slot, to find the first start time of the first highlighted block?

     

     

    var d = eventArgs.get_startTime();

     

     

     

    The line above always returns the start time of the currently selected time slot where the right mouse is clicked, NOT the start time of the selected block of time slots.


    Dave Penny
  10. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 07 Dec 2010 Link to this post

    Julio,

    The code I am using is shown below, and works (although I still cannot get the real start time of the highlighted block of time):

    function AppointmentInserting(sender, eventArgs) {
        var start = formatDate(eventArgs.get_startTime());
        var timeSlot = eventArgs.get_targetSlot();
        start = formatDate(timeSlot.get_startTime());
        var duration = sender.get_durationOfSelectedArea();
        duration = duration / (1000 * 60);
        var isAllDay = eventArgs.get_isAllDay();
        var ow = window.radopen("EditEvent.aspx?Mode=Insert&Start=" + start + "&IsAllDay=" + isAllDay + "&duration=" + duration, "AdvancedForm");
        ow.set_title(eventDate);
        ow.Maximize();
        eventArgs.set_cancel(true);
        return false;
    }
  11. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 09 Dec 2010 Link to this post

    Hi David Penny,

    You can use the get_selectedSlots method of RadScheduler's client-side object representation. The slot at the first position (array is returned) is the first selected slot.


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jumpstart 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.
  12. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 10 Dec 2010 Link to this post

    Hi Nikolay,

    Any chance of a code sample showing how to use this?  I have looked in the Help files and cannot find any reference to get_SelectedSlots().  What object is returned, and how is is then used?

    Thanks

    Dave Penny
  13. David Penny
    David Penny avatar
    174 posts
    Member since:
    Jun 2006

    Posted 10 Dec 2010 Link to this post

    Nikolay,

    Ignore my last post - managed to work it out.

    My entire code is shown below, in case it's of any use to someone else:

    function AppointmentInserting(sender, eventArgs) {
        stopTimer();
        var d = eventArgs.get_startTime();
        var eventDate = displayDate(d);
        var start = formatDate(eventArgs.get_startTime());
        var slots = sender.get_selectedSlots();
        start = formatDate(slots[0].get_startTime());
        //var duration = timeSlot.get_durationOfSelectedArea();
        var duration = sender.get_durationOfSelectedArea();
        duration = duration / (1000 * 60);
        var isAllDay = eventArgs.get_isAllDay();
        var ow = window.radopen("EditEvent.aspx?Mode=Insert&Start=" + start + "&IsAllDay=" + isAllDay + "&duration=" + duration, "AdvancedForm");
        ow.set_title(eventDate);
        ow.Maximize();
        eventArgs.set_cancel(true);
        return false;
    }


    Dave Penny
  14. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 15 Dec 2010 Link to this post

    Hi David Penny,

    I am glad you managed to solve this!

    If you experience hard time with something else, though, please, feel free to write to us, again! We are happy to help!


    Regards,
    Nikolay Tsenkov
    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.
  15. Kevin
    Kevin avatar
    17 posts
    Member since:
    Jul 2012

    Posted 01 Nov 2012 Link to this post

    Is this the only way to get start time and end time when a user selects a time slot (javascript from client side)?  How about getting the time selected from codebehind?
  16. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 05 Nov 2012 Link to this post

    Hello Kevin, 

     
    You can get the Start and the end of the TimeSlot as in the code below:

    protected void RadScheduler1_FormCreating(object sender, SchedulerFormCreatingEventArgs e)
       {
           DateTime start = e.Appointment.Start;
           DateTime end=e.Appointment.Start.AddMinutes(((RadScheduler)sender).MinutesPerRow);
     
           Response.Write("Start:"+start+"<br/>"+"End"+end);
       }

    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
UI for ASP.NET Ajax is Ready for VS 2017