如何禁用剑道编辑器或使其只读?我尝试使用 HTML 属性但没有运气(或者我仍然做对了)
@(Html.Kendo().Editor()
.Name("Text")
.Value(@detail.SRoomInformation)
.Tools(tools => tools.Clear())
)
如何禁用剑道编辑器或使其只读?我尝试使用 HTML 属性但没有运气(或者我仍然做对了)
@(Html.Kendo().Editor()
.Name("Text")
.Value(@detail.SRoomInformation)
.Tools(tools => tools.Clear())
)
如果您想知道为什么没有诸如启用/禁用之类的选项 - 因为 html 可以简单地显示为 html 或文本 - 不需要编辑器提供的所有工具,使用此类小部件毫无意义。编辑器意味着它可以帮助您编辑;)
如果您真的想禁用它,您可以在初始化编辑器后使用以下代码行
例如
@Html.Kendo().Editor().Name("test")
<script type="text/javascript">
$(function () {
$($('#test').data().kendoEditor.body).attr('contenteditable', false)
})
</script>
不知道为什么回答的问题对我不起作用。但无论如何,它引发了类似的事情:
@(Html.Kendo().EditorFor(model => model.Description) )
@Html.ValidationMessageFor(model => model.Description)
<script>
// this piece of code neeeeeeeds to be heeeeere! Don't move it
$(document).ready(function () {
var editor = $('#Description').data('kendoEditor');
editor.body.contentEditable=false;
});
</script>
这有效!:) 玩得开心!
当我尝试实施它们时,上述解决方案都不适合我。Telerik 似乎为此提供了一个非常简单的解决方案,涉及覆盖的 div,如记录在:http ://docs.telerik.com/kendo-ui/controls/editors/editor/how-to/enable-and-disable-编辑
在实践中,这导致我想禁用的控件旁边有一个额外的 div:
<div ng-if="readonly/disabled_Condition == true">
<div id="overlay" style="width:100%;height:250px; top:100; position:absolute; background-color: black; opacity:0.1; z-index:2;"></div>
<textarea kendo-editor k-options="options.DutyEditor" ng-model="item.TasksHtml"></textarea>
</div>
一个问题是将覆盖的 div 的大小与您的剑道编辑器的大小相匹配。就我而言,它是一个简单的 100% 宽度和 250 像素高度,所以我很幸运。
认为这可能对某人有帮助!