Jquery将div中的所有控件设置为只读 - telerik控件不是只读

时间:2017-04-27 18:24:25

标签: jquery html telerik telerik-mvc

尝试将a中的所有控件默认为只读,但Telerik似乎不想转为只读。

示例html

                        @ Html.LabelFor(model => model.Entity.IssueDate,htmlAttributes:new {@class =" control-label col-md-2"})                                                      @ Html.EditorFor(model => model.Entity.IssueDate,new {htmlAttributes = new {@class =" form-control"}})
                                             

                <div class="form-group">
                    <label class="control-label col-md-2">
                        Product
                    </label>
                    <div class="col-md-10">
                        @(Html.Kendo().DropDownListFor(m => m.Entity.ProductId)
                                      .DataTextField("Text")
                                      .DataValueField("Value")
                                      .Filter("contains")
                                      .HtmlAttributes(new { @class = "form-control" })
                                      .BindTo(new SelectList(Model.Products, "Id", "FullName", Model.Entity.ProductId)))
                    </div>
                </div>

和一段代码

  <script>
    $(document).ready(function () {

        if ($("#EventCommand").val() == "detail") {

            $(".form-control").prop("readonly", true);
        }

    });

</script>

插入以下行似乎有效,但我想要一些足够通用的东西来处理div标签内的所有控件(都具有form-control标签)。

$(&#34;#Entity_ProductId&#34)的数据。(&#34; kendoDropDownList&#34)只读(真);

任何想法为什么Telerik mvc kendo组件似乎都不想像普通的html控件那样尊重readonly属性。

1 个答案:

答案 0 :(得分:0)

您是否尝试过在组件上使用HtmlAttribute?

.HtmlAttributes(new { @readonly = "readonly" })

我测试了它并且工作得很好