2 Answers, 1 is accepted
Hi Grant,
I understand the need in such a scenario. You have right.
Currently, the DateTimePicker doesn't have the possibility to open the Time page by default. As a result, I opened a feature request on your behalf on our Public Feedback Portal:
Allow the DateTimePicker to open the Time portion/page by default
This feature will allow you to achieve the desired result.
We prioritize feature requests based on community demands and interests. I already added your vote there.
You are also automatically subscribed to receive email notifications for status updates.
Regards,
Hristian Stefanov
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
FYI, I found a javascript work-around that seems to allow the TIME tab to be auto-selected when the picker is opened. First set the OnOpen event:
<TelerikDateTimePicker Id="expectedCheckInTime" @bind-Value="CheckoutCrewViewModel.ExpectedCheckinTime" Format="MMM dd, hh:mm tt" OnOpen="@OnCheckInDateTimePickerOpen">
<DateTimePickerSteps Minute="5" />
</TelerikDateTimePicker>
In your @code:
@inject IJSRuntime JsRuntime
private async Task OnCheckInDateTimePickerOpen(DateTimePickerOpenEventArgs args)
{
await JsRuntime.InvokeVoidAsync("switchToTimeTab", "expectedCheckInTime");
}
In your script.js file:
function switchToTimeTab(pickerId) {
setTimeout(function () {
const picker = document.querySelector('.k-datetime-wrap-md');
if (picker) {
const timeTab = picker.querySelector('.k-button-group-stretched button.telerik-blazor.k-button:not(.k-selected) span.k-button-text');
if (timeTab && timeTab.textContent.trim() === 'Time') {
timeTab.closest('button').click();
}
}
}, 100); // Slight delay before clicking to allow popup to appear.
}
Credit goes to Claude AI for that solution (GPT wasn't able to figure it out). Hope that helps! :)
Hi Andrew,
Thank you for sharing the workaround you have found. This will help other developers facing the same scenario.
Your effort is highly appreciated.
Kind Regards,
Hristian
function switchToTimeTab() { setTimeout(() => { const timeButton = [...document.querySelectorAll( '.k-datetimepicker-popup .k-segmented-control-button:not(.k-selected)')] .find(b => b.textContent.trim() === 'Time'); timeButton?.click(); }, 100); // Slight delay so the popup is rendered first. }
Though it looks a little wonky because of the animation Telerik has added to make the time part "scroll" into view so it you don't like that whirlwind effect as the calendar whooshes away while the picker pops up, there is a more complicated fix:
function switchToTimeTab() { document.body.classList.add('dt-switching'); const reveal = () => document.body.classList.remove('dt-switching'); const started = performance.now(); let target = null; const tick = () => { if (target) { // Switched — let it paint in place, then show it. if (target.querySelector('.k-time-tab')) { requestAnimationFrame(reveal); return; } } else { // The popup that just opened is the one still on the Date tab. // A previous picker's popup can linger in the DOM while it closes. target = [...document.querySelectorAll('.k-datetimepicker-popup')] .find(p => p.querySelector('.k-date-tab')) ?? null; const timeButton = target && [...target.querySelectorAll('.k-segmented-control-button')] .find(b => b.textContent.trim() === 'Time'); if (timeButton) timeButton.click(); else target = null; // not rendered yet, try next frame } // Safety valve so the popup never stays hidden. if (performance.now() - started > 1000) { reveal(); return; } requestAnimationFrame(tick); }; requestAnimationFrame(tick); }with CSS:
body.dt-switching .k-datetimepicker-popup { visibility: hidden; } body.dt-switching .k-datetimepicker-popup * { transition: none !important; }
of course, it'll all break the next time Progress changes their css name tags again :) enjoy!
