
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
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

get_durationOfSelectedArea()
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

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.

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

Image attached.

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

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;
}
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

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

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
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

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