This is a migrated thread and some comments may be shown as answers.

DatePicker does not update the value in view

4 Answers 5617 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Gerald
Top achievements
Rank 1
Gerald asked on 26 Jul 2012, 02:22 PM
Hi all,

I am using a date picker along with two links - one for going one day backward and one for going one day forward. Each link calls a javascript-function which updates the value of the date picker. The internal date is set correctly but the value in the textfield next to the date picker is not updated.
The error occurs both when I am using a date object [1] and a formatted date string [2] for setting the value.

Is this a bug or am I missing something?

Many thanks in advance!

[1] http://jsfiddle.net/pwhmF/
[2] http://jsfiddle.net/UG2hc/

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Jul 2012, 07:49 AM
Hello Gerald,

 
The DatePicker will not apply the "new" date if it is the same as its internal value. When you can the date in the method and just set is date, then the internal date of the DatePicker is set too. This is expected, because the Date in JavaScript is passed by reference, not by value. Here is the correct way to work with dates:

window.forwardDate = function() {
    var datePicker = $("#datepicker").data("kendoDatePicker");
 
    // add one day
    var date = new Date(datePicker.value())
    date.setDate(date.getDate() + 1);
 
    // set new date
    datePicker.value(date);
 
    datePicker.trigger("change");
}

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gerald
Top achievements
Rank 1
answered on 27 Jul 2012, 09:11 AM
Thanks a lot for the hint! Problem solved!
0
Anand
Top achievements
Rank 1
answered on 01 Oct 2019, 03:48 PM

I am trying to use kendo in my existing core application and just started with adding kendodatepicker but having two issues:

1. I see some bar "|" coming before and after that control I use Kendodatepicker may be because I use "Form-control" class too

2. on my save my kendodatepicker refresh to today's date instead of preserving old value..

so i tried to manually hold the old value and set back after save in jquery (which I dont prefer to do) but still dint work.

please suggest if I am missing any point..

0
Georgi
Telerik team
answered on 04 Oct 2019, 10:19 AM

Hello Anand,

Could you please share the configuration of the widget with us? Are you using the plain jQuery library or the .Net Core server wrappers?

Regarding the `bars`, by default we do not render any sort of borders, so I believe it is caused by some other css. You could examine the element and find out which style rule adds it, then you could override it.

Regards,
Georgi
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Date/Time Pickers
Asked by
Gerald
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Gerald
Top achievements
Rank 1
Anand
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or