Hi,
I am trying to enable/disable date pickers depending on other widgets (checkboxes and numeric text boxes). When I try to call DatePicker.enable() with true or false as a parameter, i get an error because the DatePicker isn't ready yet. Seems like Kendo widgets aren't ready until $(document).ready too. Are there any events or something that would tell me when the date picker is ready to be manipulated ? For now I am using a setTimeout which feels really wrong.
Here is a sample of my code.
I thank you in advance.
I am trying to enable/disable date pickers depending on other widgets (checkboxes and numeric text boxes). When I try to call DatePicker.enable() with true or false as a parameter, i get an error because the DatePicker isn't ready yet. Seems like Kendo widgets aren't ready until $(document).ready too. Are there any events or something that would tell me when the date picker is ready to be manipulated ? For now I am using a setTimeout which feels really wrong.
Here is a sample of my code.
1.
$(document).ready(
function
() {
2.
ChangeDatePickersState();
3.
});
01.
function
ChangeDatePickersState() {
02.
var
input = $(
'#MyCheckbox:checked'
)
03.
var
bool = input.length != 0 ?
true
:
false
;
04.
EnableDatePickerForCheckbox(
'MyDatePicker'
, bool);
01.
function
EnableDatePickerForCheckbox(inputName, inputValue) {
02.
var
datePicker = $(
'#'
+ inputName).data(
"kendoDatePicker"
);
03.
if
(inputValue ==
true
) {
04.
datePicker.enable(
true
);
05.
}
06.
else
{
07.
datePicker.enable(
false
);
08.
datePicker.value(
null
);
09.
}
10.
}
I thank you in advance.