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.


Sachin SinghRank #66 · 26.2K reputationPosted Jun 19, 2022, 5:23 AM EDT
Aniket NarvankarRank #903 · 2.3K reputationPosted Jun 19, 2022, 5:55 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 19, 2022, 6:08 AM EDT
Aniket NarvankarRank #903 · 2.3K reputationPosted Jun 19, 2022, 6:14 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 19, 2022, 6:25 AM EDT
Aniket NarvankarRank #903 · 2.3K reputationPosted Jun 19, 2022, 6:29 AM EDT
Aniket NarvankarRank #903 · 2.3K reputationPosted Jun 19, 2022, 6:53 PM EDT
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.