Reputation: 23
I have a popup with kendo grid inside that displays records, the first column is
col.Bound(m => m.RecordDate)
.EditorTemplateName("DateTime")
.Width(180).Format("{0:dd/MM/yyyy h:mm tt}");`
This is the DateTime
in EditorTemplate
-
@(Html.Kendo().DateTimePickerFor(m => m)
.HtmlAttributes(new { data_bind = dataBind}))`
The problem is when I go to that view, and create a record let's say current datetime is 19/10/2017 8:30 AM
when i save the record it get's the correct time, the grid is reloaded but the popup is not being closed and then let's say 3 minutes have passed, and I create a record again but the datetimepicker's default value is still 19/10/2017 8:30 AM
, instead of 19/10/2017 8:33 AM
Upvotes: 2
Views: 137
Reputation: 3689
Since the window is not being closed then the binded dateTime to the datePicker will allways the be the dateTime that was binded the first time the window was loaded. The element doesn't refresh and there isn't any configuration for it to always get the current DateTime since it is not possible.
If for example you open any window and until your save a couple of minutes have passed the value of the dateTime will again be wrong. If you want the absolute moment of the save you can't give it to the user to insert it or alter it. You should set it at the save event at that exact moment that the save occurs
If however you still want to allow the user to handle that dateTime one way I can think of is to reset the dateTimePicker value to Date.now() every time the user focuses to the window. Obviously you will still have the issue of the time passing while the user inserts his data...
Upvotes: 1