Time Picker - Default to AM or PM programmatically

1 Answer 43 Views
DateTimePicker TimePicker
Leslie
Top achievements
Rank 1
Leslie asked on 19 Nov 2021, 03:08 AM | edited on 19 Nov 2021, 04:26 AM

Hi,

I was wondering if it is possible to default the AM/PM designator programmatically, without having to set an actual time value to the time picker?

The min property does work, however it does not seem to synchronise with the AM/PM designator on the actual input field.

For example, if I've set the min to be 1:00PM, then the list actually does not have the AM available - which is correct. However, the input field still has "hh:mm am" displaying.

I suppose one other way could be to change the dayPeriod placeholder text from AM to PM, if that is at all possible using the currently existing API.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Nov 2021, 12:06 PM

Hi Leslie,

Setting the min and max properties of the TimePicker component is the right way to go. Then the options in the popup will be reduced according to the set restrictions. If the selected time value is out of this range (like changing the time or the AM/PM segment with arrow keys or scroll), the component triggers a validation error. 

Alternatively, to prevent typing an out-of-range value, you can render the input in a read-only state, allowing the user to choose a value only from the popup. Please check the following topic for more details:

https://www.telerik.com/kendo-angular-ui/components/dateinputs/timepicker/readonly-state/#toc-read-only-input

I hope this helps.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Leslie
Top achievements
Rank 1
commented on 24 Nov 2021, 04:16 AM

Hi Martin,

Thanks for your response.

"...however it does not seem to synchronise with the AM/PM designator on the actual input field."

I guess to confirm my observation above, it is currently not possible, since the user will need to manually type "pm" or use the arrow keys to switch between "am" and "pm" in the text field itself.

Martin
Telerik team
commented on 26 Nov 2021, 01:08 PM

Hi Leslie,

If I understand correctly when the popup is opened a default time and AM/PM designator needs to be focused without selecting it actually. The current behavior, when the TimePicker has no value, is to focus at 12:00 AM by default.

Indeed currently there is no focusedTime property or similar, which would allow focusing a custom time when opening the popup. However, there is a feature request logged in our Feedback portal where we track the customer demand for it. Please cast your vote as well.

https://feedback.telerik.com/kendo-angular-ui/1470485-i-want-to-set-a-default-time-on-datetime-picker

In case I misunderstood the requirement, please could I ask to provide some more details regarding this query and how the TimePicker is expected to work in this case step by step. Thank you in advance.

 

Tags
DateTimePicker TimePicker
Asked by
Leslie
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or