Search code examples
jqueryasp.net-mvcrazorkendo-ui

how to disable kendo ui dropdown list with jquery?


Here is the render html code from browserI 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.


Solution

  • Use enable method of the widget.

    $("#CallTypeId").data("kendoDropDownList").enable(false);