Hamdi Baligh
Hamdi Baligh

Reputation: 892

Kendo Editor - Remove toolbar

I am using kendo Editor and though... I want to disable the edit toolbar. Indeed, All I want is to have the possibility to format my textarea (bold, italic...) without allowing the user to interact with my textarea neither have a toolbar which will be very confusing to a user. I want it to be displayed like a normal readonly textarea, nothing else. I tried this :

$("#output").kendoEditor();
$($('#output').data().kendoEditor.body).attr('contenteditable', false);

But it's not working. Any ideas?

Edit

I just want to have a simple textarea, I want to hide the toolbar and manipulate the content of the textarea programmatically since it is readonly.

Upvotes: 4

Views: 14119

Answers (4)

suleymanduzgun
suleymanduzgun

Reputation: 425

Hide toolbar with css:

.k-editor-toolbar {
    display: none !important;
}

This works for me (Asp.Net Core 3.0)...

Upvotes: 2

David
David

Reputation: 49

This works well in MVC using HTML wrappers

 @(Html.Kendo().EditorFor(m => m.Body).Tools(t => t.Clear()))

Upvotes: 5

OnaBai
OnaBai

Reputation: 40917

If you don't want to show the toolbar define an empty tools in the KendoUI editor initialization:

$("#editor").kendoEditor({
    // Empty tools so do not display toolbar
    tools: [ ]
});

See it here http://jsfiddle.net/OnaBai/Eh6X2/

If you want to disable the edition, you should use:

// Disable edition
$(editor.body).attr('contenteditable',false);

And the following code selects all the text and converts it to bold, then deselects it.

var range = editor.createRange();
range.selectNodeContents(editor.body);
editor.selectRange(range);
editor.exec("bold");
editor.selectRange();

The full example here: http://jsfiddle.net/OnaBai/Eh6X2/3/

Upvotes: 4

Jaimin
Jaimin

Reputation: 8020

if you want your kendoEditor textarea readonly then use below code,

$('iframe').contents().find("body").attr('contenteditable',false);

and if you want to disabled your toolbar then use this code,

$('.k-editor-toolbar').find('li a').click(function(){return false;})

Hide toolbar

$('.k-editor-toolbar').hide();

Upvotes: 1

Related Questions