Unable to make Telerik dropdownlist read-only

I am trying to make a Kendo dropdownlist read-only via Javascript based on a boolean. I've been looking through various tutorials and stackoverflow questions but have yet to get something to help me. Here is what I have so far:

dropdownlist:

@(Html.Kendo().DropDownList()
          .Name("ddlConsultantCompany")
          .HtmlAttributes(new { style = "width: 300px;" })
          .DataTextField("CompanyName")
          .DataValueField("CompanyId")
          .Value(Model.Consultant.CompanyID.ToString())
          .DataSource(source =>
                      source.Read(read =>
                                  read.Action("GetCompanies", "DropDown")))
)

Javascript:

var ddlConsultantCompany = document.getElementById("ddlConsultantCompany");

I know I am triggering the javascript as I had set up a couple of alerts to tell me how far I have gotten in the process. I inspected the webpage itself and know that the ID for the dropdownlist is ddlConsultantCompany. Here are a few of the things that I have tried:

ddlConsultantCompany.readonly();
ddlConsultantCompany.enable(true);

I also looked up the actual guide from Telerik and haven't been able to get that to work either(Telerik tutorial1).

1 answer

  • answered 2018-09-11 16:45 Jin Thakur

     $("#dropdownID").attr("disabled", "disabled");