Hello,
I have a datepicker with validation rule that calculates a new date, if the input is a number.
E.g. if today is 12/24/2016 and I type in 2 I get the date 12/26/2016.
This works fine. By validation the right date is set.
But if the datefield is in a grid, the date is not always set, only every second time.
This happens if I type in a number and after that i click on another gridcolumn.
It works, if I type in a number and then press enter-key or tab-key or click outside the gid.
Does the validation works different by clicking on the grid and hitting the enter/tab key, ?
The validation function is:
01.
var
customDateValidation =
function
(e, field) {
02.
var
input = $(e).val();
03.
if
(!isNaN(input)) {
04.
var
noOfDays = parseInt(input);
05.
if
(noOfDays > -366 && noOfDays < 366) {
06.
var
newDate =
new
Date();
07.
newDate.setDate(newDate.getDate() + noOfDays);
08.
09.
var
item = $(
"#myGrid"
).data(
"kendoGrid"
).dataItem($(e).closest(
"tr"
));
10.
item[field] = newDate;
11.
item.dirty =
true
;
12.
13.
return
true
;
14.
}
15.
return
false
;
16.
}
17.
18.
var
date = kendo.parseDate(input,
"dd.MM.yyyy"
);
19.
if
(date) {
20.
return
true
;
21.
}
22.
23.
if
(input ==
null
|| input ==
""
) {
24.
return
true
;
25.
}
26.
return
false
;
27.
};
Or is there another way to turn integers to date with a grid datefield?
Thanks in advance