This is a migrated thread and some comments may be shown as answers.
The DatePicker doesn't update its value with focus on its input field
2 Answers 19 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kai-Tobias
Top achievements
Rank 1
Kai-Tobias asked on 20 May 2011, 03:00 PM
Hi,

In my application, a DatePicker is used to save a specific date.
A Button is used to save the data. The user wanted to be able to use a shortcut, so I attachet the accesskey attribute to the button.

If I enter a value into the DatePicker and click on the button, the value is correctly fetched from the DatePicker.
Now the problem:
If I enter or change the value of the DatePicker and leave the cursor inside the input field and press the shortcut "Alt+s" instead of clicking the button, the old value instead of the new one is fetched.

Any ideas how I could avoid that problem and make the DatePicker update the value before I get the value using JavaScript?

I attached a small sample project for testing this.

Best regards
Kai

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 20 May 2011, 03:48 PM
Hi Kai,

The DatePicker component parses and updates its value on certain events, e.g. mousedown or keydown. When using access keys, these events are not fired, so you need to initiate a value update manually:

function getValue() {
    var pickerEl = $("#TestDP");
    var pickerObj = pickerEl.data("tDatePicker");
    pickerObj._update(pickerEl.val());
    alert(pickerObj.value());
}


All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kai-Tobias
Top achievements
Rank 1
answered on 20 May 2011, 04:56 PM
Hi Dimo,

thanks for the quick reply!
This is exactly what I was looking for. Now everything works perfectly fine, thank you.

best regards
Kai
Tags
Date/Time Pickers
Asked by
Kai-Tobias
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Kai-Tobias
Top achievements
Rank 1
Share this question
or