Add save button in ASP.NET CORE Document editor toolbar
5 Jul 20242 minutes to read
To add a save button to the existing toolbar in DocumentEditorContainer
DocumentEditorContainer allows you to add a new button to the existing items in a toolbar using [CustomToolbarItemModel
] and with existing items in toolbarItems
property. Newly added item click action can be defined in toolbarclick
.
<ejs-documenteditorcontainer id="container" created="onDocCreate"></ejs-documenteditorcontainer>
<script>
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 = ['New','Open',toolItem, 'Separator' ,'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 (args.item.id) {
case 'Custom':
container.documentEditor.save('Sample', 'Docx');
break;
}
};
}
</script>
NOTE
Default value of
ToolbarItems
is['New', 'Open', 'Separator', 'Undo', 'Redo', 'Separator', 'Image', 'Table', 'Hyperlink', 'Bookmark', 'TableOfContents', 'Separator', 'Header', 'Footer', 'PageSetup', 'PageNumber', 'Break', 'InsertFootnote', 'InsertEndnote', 'Separator', 'Find', 'Separator', 'Comments', 'TrackChanges', 'Separator', 'LocalClipboard', 'RestrictEditing', 'Separator', 'FormFields', 'UpdateFields','ContentControl']
.