Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i disable kendo editor in asp.net mvc

Tags:

kendo-ui

How can I disable kendo editor or make it read only? I tried using HTML attribute but no luck ( or I still do it right)

                    @(Html.Kendo().Editor()
                    .Name("Text")
                    .Value(@detail.SRoomInformation)
                    .Tools(tools => tools.Clear())
                    )
like image 767
user1392853 Avatar asked Mar 03 '13 05:03

user1392853


2 Answers

If you are wondering why there is no such option such as Enable/Disable - because html could be simply shown as html or as text - all the tools the Editor provide are not needed and it is pointless to use such widget. Editor means it helps you edit ;)

If you really want to make it disabled you can use the following line of code after initializing the Editor

e.g.

@Html.Kendo().Editor().Name("test")


<script type="text/javascript">
    $(function () {
        $($('#test').data().kendoEditor.body).attr('contenteditable', false)
    })        
</script>
like image 128
Petur Subev Avatar answered Nov 14 '22 22:11

Petur Subev


No Idea why the answered question didn't work for me. But anyway, it sparked something like:

@(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>

And this worked!:) Have fun!

like image 36
mauricio_martins Avatar answered Nov 14 '22 22:11

mauricio_martins