I am using a Kendo DatePicker
@Html.Kendo().DatePicker().Name("RunDateDisplay").HtmlAttributes(new { type = "text", @Style = "width: 100px;", tabIndex = "13" }).Format("MM/dd/yyyy")
I want to make it readonly on page loads and when user checkbox make it readonly false.
This is what i have done. On document.ready wrote this
$("#RunDateDisplay").attr("readonly","readonly"); to make this readonly and on checkbox click did this
$("#RunDateDisplay").removeAttr('readonly');
but this is not working. calendar is not loading,please let me know how this could be done.

Aniket NarvankarPosted Jun 19, 2022, 10:53 PM
hi sachin,got one solution from this link
https://docs.telerik.com/kendo-ui/api/javascript/ui/datepicker/methods/readonly
but on document.ready event when i wrote this
var datepicker = $("#RunDateDisplay").data("kendoDatePicker");
datepicker.readonly();
this give error when wrote on document.ready error was can not read property readonly of undefined. this is did not understood.
so did it in this way
@Html.Kendo().DatePicker().Name("RunDateDisplay").HtmlAttributes(new { type = "text", @Style = "width: 100px;", tabIndex = "13",@readonly="readonly" }).Format("MM/dd/yyyy")
and then on checkbox checked event wrote this
var datepicker = $("#RunDateDisplay").data("kendoDatePicker");
datepicker.readonly(false);
and again when i unchecked checkbox wrote this to make it readonly
var datepicker = $("#RunDateDisplay").data("kendoDatePicker");
datepicker.readonly();
this is working as required,but do not know why when written on document.ready it give error.
Aniket NarvankarPosted Jun 19, 2022, 10:29 AM
Sachin SinghPosted Jun 19, 2022, 10:25 AM
Aniket NarvankarPosted Jun 19, 2022, 10:14 AM
Sachin SinghPosted Jun 19, 2022, 10:08 AM
Aniket NarvankarPosted Jun 19, 2022, 9:55 AM
Sachin SinghPosted Jun 19, 2022, 9:23 AM