166
Views
6
Comments
Solved
Focus on date picker when opening a Pop-up

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?

2022-12-09 09-54-41
Gaurav Rawat
Solution

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

2025-04-15 04-00-33
Prakhar Sharma

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

2022-12-09 09-54-41
Gaurav Rawat
Solution

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

2017-06-02 10-47-12
René van Britsem

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.


2022-12-09 09-54-41
Gaurav Rawat

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.

Thanks,

Gaurav Rawat

2017-06-02 10-47-12
René van Britsem

I tried it again and it works. Thx for helping.

2022-12-09 09-54-41
Gaurav Rawat

Glad to help you.

Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.