saleem saleem - 3 months ago 24
Javascript Question

How to change disabled attribute of Kendo TimePicker?

I need some help with my mvc application.

I am using the following code to create a Kendo TimePicker.

@(Html.Kendo().TimePicker().Name("FirstShiftFrom" + prop.PropertyName.Substring(0, 3))
.HtmlAttributes(new { @class = "workHoursTimePicker " + prop.PropertyName ,@disabled = "disabled" ,style="width:85px"})


How can I enable this control?

I have tried this in js :

document.get.Element.By.Id("id").disabled = false;


but it is not working!

Answer

Instead of using HTML disabled attribute to disable the Kendo Time picker use Enable method of Kendo Time picker widget.

e.g.

@(Html.Kendo().TimePicker().Name("FirstShiftFrom" + prop.PropertyName.Substring(0, 3))
                       .HtmlAttributes(new { @class = "workHoursTimePicker " + prop.PropertyName, style = "width:85px" })
                       .Enable(false))

This will disable the Time picker and to enable it use this in javascript:

$("#TimePickerId").data("kendoTimePicker").enable(true);

Hope this helps!

Comments