how to disable kendo ui dropdown list with jquery?
Solution 1
Use enable method of the widget.
$("#CallTypeId").data("kendoDropDownList").enable(false);
Solution 2
After comments i can say that you just don't get your select
. you should select it like this in your case i suppose:
$(document).ready(function ()
{
debugger;
var result = '@TrackingHelper.CurrentUser.IsViewTestCallType';
if (result == "False")
{
$("select[name=CallTypeId]").prop("disabled", "disabled");
}
});
If you want to use id
selector like you do already you should check what id generete your Kendo().DropDownListFor
R K Sharma
I have been working as developer since 6 and half year and I never got boredom of it. I like new challenges because it makes me feel alive and this job feeds me with what I want. Honestly I am proud of what I do and I love to share all my knowledge that I have with interested people. This place would be more beautiful and you would be more great-full to god if you know how program works and runs over a compute. You are the greatest program on earth created by god, we are limitless;
Updated on June 15, 2022Comments
-
R K Sharma almost 2 years
I am using kendo UI dropdownlist, I am new to kendo UI. I want to disable the dropdownlist if @TrackingHelper.CurrentUser.IsViewTestCallType return False.
@(Html.Kendo().DropDownListFor(i => i.CallTypeId) .Name("CallTypeId") .HtmlAttributes(new { style = "width:100%" }) .DataTextField("MasterValueName") .DataValueField("MasterValueId") .Events(x => x.Open("ManageSecurity")) .DataSource(source => { source.Read(read => { read.Action("GetCallType", "Common", new { Area = "" }); }); }) .OptionLabel("Select Call Type") )
I am doing this in jquery:
$(document).ready(function () { debugger; var result = '@TrackingHelper.CurrentUser.IsViewTestCallType'; if (result == "False") { $("#CallTypeId").prop("disabled", true); } });
Any suggestion will be appreciated. Thanks in advance.
-
R K Sharma over 8 yearsI have tested the selector, its fine, and also tried your suggestion, but its still not working :(
-
R K Sharma over 8 yearsI have added screen shot of rendered html in my question
-
R K Sharma over 8 yearsI was trying it this way var drp= $("#CallTypeId").data("kendoDropDownList"); drp.options.enabled = false; Thanks man for your help, you have saved my lots of time. god bless you @uygar donduran