Skip to content

Commit 51dbc2e

Browse files
Merge pull request #4137 from syncfusion-content/938302-sub-menu-cm
938302: Added code for custom context menu with sub-menu items.
2 parents b0529ed + 6ce4922 commit 51dbc2e

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@Html.EJS().DocumentEditorContainer("container").Created("onCreated").EnableToolbar(true).Render()
2+
3+
<script>
4+
var documenteditor;
5+
var container;
6+
function onCreated() {
7+
var documenteditorElement = document.getElementById("container");
8+
container = documenteditorElement.ej2_instances[0];
9+
documenteditor = container.documentEditor;
10+
// creating Custom Options
11+
let menuItems = [
12+
{
13+
text: 'Form field',
14+
id: 'form field',
15+
iconCss: 'e-de-formfield e-icons',
16+
items: [
17+
{
18+
text: 'Text form',
19+
id: 'Text form',
20+
iconCss: 'e-icons e-de-textform',
21+
},
22+
{
23+
text: 'Check box',
24+
id: 'Check box',
25+
iconCss: 'e-icons e-de-checkbox-form',
26+
},
27+
{
28+
text: 'Drop down',
29+
id: 'Drop down',
30+
iconCss: 'e-icons e-de-dropdownform',
31+
},
32+
],
33+
},
34+
];
35+
// adding Custom Options
36+
container.documentEditor.contextMenu.addCustomMenu(menuItems, false, true);
37+
}
38+
</script>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<div class="control-section">
2+
<ejs-documenteditorcontainer id="container" serviceUrl="/api/DocumentEditor/" enableToolbar=true created="onCreated" height="590px"></ejs-documenteditorcontainer>
3+
</div>
4+
<script>
5+
var documenteditor;
6+
var container;
7+
function onCreated() {
8+
var documenteditorElement = document.getElementById("container");
9+
container = documenteditorElement.ej2_instances[0];
10+
documenteditor = container.documentEditor;
11+
// creating Custom Options
12+
let menuItems = [
13+
{
14+
text: 'Form field',
15+
id: 'form field',
16+
iconCss: 'e-de-formfield e-icons',
17+
items: [
18+
{
19+
text: 'Text form',
20+
id: 'Text form',
21+
iconCss: 'e-icons e-de-textform',
22+
},
23+
{
24+
text: 'Check box',
25+
id: 'Check box',
26+
iconCss: 'e-icons e-de-checkbox-form',
27+
},
28+
{
29+
text: 'Drop down',
30+
id: 'Drop down',
31+
iconCss: 'e-icons e-de-dropdownform',
32+
},
33+
],
34+
},
35+
];
36+
// adding Custom Options
37+
container.documentEditor.contextMenu.addCustomMenu(menuItems, false, true);
38+
}
39+
</script>

ej2-asp-core-mvc/document-editor/how-to/customize-context-menu.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,27 @@ The following code shows how to hide or show added custom option in context menu
9090
{% endhighlight %}{% endtabs %}
9191
{% endif %}
9292

93+
#### Customize Context Menu with sub-menu items
94+
95+
Document Editor allows you to customize the Context Menu with sub-menu items. It can be achieved by using the `addCustomMenu()` method.
96+
97+
The following code shows how to add a sub items in the custom option in context menu in Document Editor Container.
98+
99+
{% if page.publishingplatform == "aspnet-core" %}
100+
101+
{% tabs %}
102+
{% highlight cshtml tabtitle="CSHTML" %}
103+
{% include code-snippet/document-editor-container/customize-sub-context-menu/tagHelper %}
104+
{% endhighlight %}
105+
{% highlight c# tabtitle="Customize-sub-context-menu" %}
106+
{% endhighlight %}{% endtabs %}
107+
108+
{% elsif page.publishingplatform == "aspnet-mvc" %}
109+
110+
{% tabs %}
111+
{% highlight razor tabtitle="CSHTML" %}
112+
{% include code-snippet/document-editor-container/customize-sub-context-menu/razor %}
113+
{% endhighlight %}
114+
{% highlight c# tabtitle="Customize-sub-context-menu" %}
115+
{% endhighlight %}{% endtabs %}
116+
{% endif %}

0 commit comments

Comments
 (0)