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

Getting end time of slot

14 Answers 173 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
David Penny
Top achievements
Rank 2
David Penny asked on 25 Nov 2010, 01:54 PM
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

14 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 30 Nov 2010, 10:26 AM
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.
0
Julio Morel
Top achievements
Rank 1
answered on 02 Dec 2010, 03:10 PM
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()
0
Nikolay Tsenkov
Telerik team
answered on 07 Dec 2010, 01:38 PM
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.
0
Julio Morel
Top achievements
Rank 1
answered on 07 Dec 2010, 01:53 PM
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.
0
David Penny
Top achievements
Rank 2
answered on 07 Dec 2010, 04:08 PM
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

 

0
Julio Morel
Top achievements
Rank 1
answered on 07 Dec 2010, 04:21 PM
Sorry, but I'm still getting this error.
Image attached.
0
David Penny
Top achievements
Rank 2
answered on 07 Dec 2010, 04:33 PM
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
0
David Penny
Top achievements
Rank 2
answered on 07 Dec 2010, 04:38 PM
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;
}
0
Nikolay Tsenkov
Telerik team
answered on 09 Dec 2010, 07:21 PM
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.
0
David Penny
Top achievements
Rank 2
answered on 10 Dec 2010, 04:19 PM
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
0
David Penny
Top achievements
Rank 2
answered on 10 Dec 2010, 06:17 PM
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
0
Nikolay Tsenkov
Telerik team
answered on 15 Dec 2010, 01:57 PM
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.
0
Kevin
Top achievements
Rank 1
answered on 01 Nov 2012, 03:58 PM
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?
0
Plamen
Telerik team
answered on 05 Nov 2012, 11:28 AM
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.
Tags
Scheduler
Asked by
David Penny
Top achievements
Rank 2
Answers by
Nikolay Tsenkov
Telerik team
Julio Morel
Top achievements
Rank 1
David Penny
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or