Hi, I’m using the DatePicker Widget in a Popup. When opening the pop-up I want to be able to start entering a date right away. For this, the focus must be set on the DatePicker.
I used the SetFocus action but that didn't work and I also tried the Autofocus = true.
Does anyone have an idea?
Hi @rRené van Britsem
we cannot able to set the focus on textbox directly on open on pop-up because datepicker input are in readonly, that why focus is not able to set.
Alternate way you can do is like this.
You need to handle on the datepicker Initialized event.
like this.
on pop open u will get pop-up open with datepicker open.
Thanks,
Gaurav Rawat
For setting the focus on the input field, you can use a piece of Javascript code that will actually click the field.
JS:
function ButtonOnClick(InputFieldId)
{
document.getElementById('$parameters.InputFieldId').click();
}
Try to create something like this. As soon as the popup will open, the focus will automatically get set on the input field and you can start to type the date straight-away. However, if you want to open the date picker, then that is something that my require additional effort, but I wasn't able to achieve it.
(The ButtonOnClick action must be run on the button click and we can use the same logic to open the popup as well as put the JS code)
You can check the demo Here.
Thanks
Hi @Gaurav Rawat,
Thanks for your answer. It works but the problem is that I also use DatePickerSetEditableInput in the initialized action. And because of this the DatePickerOpen doesn't work.
Hi @René van Britsem,
I am not able to understand the DatePickerSetEditableInput.
I couldn't find any event with name in date picker .
It will be great if you share screenshot or explain it in more detail.
I tried it again and it works. Thx for helping.
Glad to help you.