尝试将a中的所有控件默认为只读,但Telerik似乎不想转向readonly .
示例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标签) .
$( “#Entity_ProductId”)的数据( “kendoDropDownList”)只读(真) .
任何想法为什么Telerik mvc kendo组件似乎不想像普通的html控件一样尊重readonly属性 .
1 回答
你试过在组件上使用HtmlAttribute吗?
.HtmlAttributes(new { @readonly = "readonly" })
我测试了它,它工作得很好