I have an issue with the minDate of the RadTimePicker.
Problem #1
My schedule is from 9AM to 2AM the next day.
I can show it properly in the time view picker.
However, when I set the MinDate and the MaxDate I am unable to select a schedule after midnight even thoug it's in the MinDate and MaxDate range.
Is there a workaround ?
Problem #2
The timeview picker won't show the last time if it's equal to EndTime.
The control will allow you to type it, but you don't see it in the timeview picker.
I patched it by adding 1 second to the end time. Is it a normal behavior ?
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
></
telerik:RadScriptManager
>
<
telerik:RadTimePicker
ID
=
"TimePicker1"
runat
=
"server"
TimeView-Interval
=
"30"
></
telerik:RadTimePicker
>
</
div
>
</
form
>
</
body
>
</
html
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
var startTime =
new
TimeSpan(9, 0, 0);
var endTime =
new
TimeSpan(1, 2, 0, 0);
TimePicker1.TimeView.StartTime = startTime;
TimePicker1.TimeView.EndTime = endTime.Add(
new
TimeSpan(0, 0, 1));
// Patch. Add 1 sec. to show the end time in the time view picker
TimePicker1.MinDate = DateTime.Today.Add(startTime);
TimePicker1.MaxDate = DateTime.Today.Add(endTime);
}
}
9 Answers, 1 is accepted
Please try to set the end date as startTime + 17 hours and see if this makes a difrenace. In your case the time span set lik
e(1, 2, 0, 0) is actually taking 12 (midnight) as value
Regards,
Maria Ilieva
Telerik by Progress
Timespan set as (1, 2, 0, 0) is not midnight but 2 AM plus 1 day.
https://msdn.microsoft.com/fr-fr/library/85ydwftb%28v=vs.110%29.aspx
public TimeSpan( int days, int hours, int minutes, int seconds
)
You can confirm by setting the selected time to this value. It really gives 2AM (see code below and attachement).
Is there a solution to use StartTime and EndTime with an EndTime after midnight ?
- I can select it from the time picker,
- I can set it server side
- I can't write the value in the textbox
var startTime =
new
TimeSpan(9, 0, 0);
var endTime =
new
TimeSpan(1, 2, 0, 0);
TimePicker1.TimeView.StartTime = startTime;
TimePicker1.TimeView.EndTime = endTime.Add(
new
TimeSpan(0, 0, 1));
// Patch. Add 1 sec. to show the end time in the time view picker
TimePicker1.SelectedTime = endTime;
TimePicker1.MinDate = DateTime.Today.Add(startTime);
TimePicker1.MaxDate = DateTime.Today.Add(endTime);
Note that the TimePicker idea is to select time in one day and not to use it for more than one days. In your case you should use DateTimePicker to be able to select hours in different days.
I hope this helps.
Regards,
Maria Ilieva
Telerik by Progress
I have the exact same issue with the DateTimePicker.
The user must be able to select time after midnight as long as it is in the MinDate and MaxDate range.
You can test the behavior with the TimePicker and the DateTimePicker.
It's not working properly.
<
telerik:RadTimePicker
ID
=
"TimePicker1"
runat
=
"server"
TimeView-Interval
=
"30"
></
telerik:RadTimePicker
><
br
/>
<
telerik:RadDateTimePicker
ID
=
"DateTimePicker1"
runat
=
"server"
DateInput-DateFormat
=
"HH:mm"
TimeView-Interval
=
"30"
></
telerik:RadDateTimePicker
>
//With TimePicker
var startTime =
new
TimeSpan(9, 0, 0);
var endTime =
new
TimeSpan(1, 2, 0, 0);
TimePicker1.TimeView.StartTime = startTime;
TimePicker1.TimeView.EndTime = endTime.Add(
new
TimeSpan(0, 0, 1));
// Patch. Add 1 sec. to show the end time in the time view picker
TimePicker1.MinDate = DateTime.Today.Add(startTime);
TimePicker1.MaxDate = DateTime.Today.Add(endTime);
//With DateTimePicker
DateTimePicker1.TimeView.StartTime = startTime;
DateTimePicker1.TimeView.EndTime = endTime.Add(
new
TimeSpan(0, 0, 1));
// Patch. Add 1 sec. to show the end time in the time view picker
DateTimePicker1.MinDate = DateTime.Today.Add(startTime);
DateTimePicker1.MaxDate = DateTime.Today.Add(endTime);
In this case the required functionality should be achieved by using two separate picker controls for start and end date. This way you will be bale to allow time frame separated in two different dates.
Regards,
Maria Ilieva
Telerik by Progress
Maybe I don't understand you or maybe you don't understand me. I'm not sure yet.
Is it possible to show me a working code sample where you are able to select a time after midnight and validate it using the built in validator ?
I will need some additional time to prepare a sample with your requirements. I will get back to you with the working code as soon as possible.
Regards,
Maria Ilieva
Telerik by Progress
This is to let you know that I'm still working on your case for assembling appropriate example the required scenario. The picker's parsing mechanism should be overwritten in order to achieve similar scenario and that is causing some problems with the control's functionality.
I will get back to you as soon as possible.
Regards,
Maria Ilieva
Telerik by Progress