jQuery将所有控件设置为Div中的所有控件以读取 - Telerik控件Arent Readonly



试图默认A中的所有控件到ReadOnly,但Telerik的所有控件似乎不想转到Readonly。

示例html

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

<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标签内的所有控件(所有人都具有形式控制标签(。

$("#Entity_ProductId").data("kendoDropDownList").readonly(true);

任何想法为什么Telerik MVC Kendo组件似乎不想以与普通HTML控件相同的方式来尊重可读性属性。

您是否尝试使用组件上的htmlattribute?

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

我对其进行了测试,它的工作正常

最新更新