Search results

Customize toolbar in ASP.NET MVC DocumentEditor control

How to customize existing toolbar in DocumentEditorContainer

DocumentEditorContainer allows you to customize(add, show, hide, enable, and disable) existing items in a toolbar.

  • Add - New items can defined by CustomToolbarItemModel and with existing items in ToolbarItems property. Newly added item click action can be defined in Toolbarclick.
  • Show, Hide - Existing items can be shown or hidden using the ToolbarItems property. Pre-defined toolbar items are available with ToolbarItem.
  • Enable, Disable - Toolbar items can be enabled or disable using enableItems
<div id="documenteditor" style="width:100%;height:100%">

    function onDocCreate() {
        var container = document.getElementById("container").ej2_instances[0];
        var toolItem = {
            prefixIcon: "e-de-ctnr-lock",
            tooltipText: "Disable Image",
            text: "Disable Image",
            id: "Custom"
        container.toolbarItems = [toolItem, 'Undo', 'Redo', 'Separator', 'Image', 'Table', 'Hyperlink', 'Bookmark', 'Comments', 'TableOfContents', 'Separator', 'Header', 'Footer', 'PageSetup', 'PageNumber', 'Break', 'Separator', 'Find', 'Separator', 'LocalClipboard', 'RestrictEditing'];
        container.toolbarClick = function (args) {
            switch ( {
                case 'Custom':
                    //Disable image toolbar item.
                    container.toolbar.enableItems(4, false);

Note: Default value of ToolbarItems is ['New', 'Open', 'Separator', 'Undo', 'Redo', 'Separator', 'Image', 'Table', 'Hyperlink', 'Bookmark', 'Comments', 'TableOfContents', 'Separator', 'Header', 'Footer', 'PageSetup', 'PageNumber', 'Break', 'Separator', 'Find', 'Separator', 'LocalClipboard', 'RestrictEditing'].