Contents
- Visibility
- Adding menu items
- Open submenu on click
- Custom header text
Having trouble getting help?
Contact Support
Contact Support
File Menu
5 Aug 202323 minutes to read
The Ribbon control provides a built-in file menu that allows you to add menu items for performing specific actions. The file menu can be enabled by setting the fileMenu property.
Visibility
You can show the file menu by setting the visible property to true
. By default, the file menu is hidden.
var tabs = [
{
header: "Home",
groups: [
{
header: "Clipboard",
collections: [
{
items: [
{
type: "Button",
buttonSettings: {
content: "Paste",
iconCss: "e-icons e-paste",
}
},
],
},
{
items: [
{
type: "Button",
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut",
}
},
{
type: "Button",
buttonSettings: {
content: "Copy",
iconCss: "e-icons e-copy",
}
},
],
}
]
}
]
}
];
var ribbon = new ej.ribbon.Ribbon({
tabs: tabs,
fileMenu: {
menuItems: [{ text: "New", iconCss: "e-icons e-file-new", id: "new" }],
visible: true
}
});
ribbon.appendTo("#ribbon");
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-ribbon/styles/material.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="ribbon"></div>
</div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Adding menu items
The menu items can be added to the file menu using the menuItems property.
var tabs = [
{
header: "Home",
groups: [
{
header: "Clipboard",
collections: [
{
items: [
{
type: "Button",
buttonSettings: {
content: "Paste",
iconCss: "e-icons e-paste",
}
},
],
},
{
items: [
{
type: "Button",
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut",
}
},
{
type: "Button",
buttonSettings: {
content: "Copy",
iconCss: "e-icons e-copy",
}
},
],
}
]
}
]
}
];
var fileMenuItems = [
{ text: "New", iconCss: "e-icons e-file-new", id: "new" },
{ text: "Open", iconCss: "e-icons e-folder-open", id: "Open" },
{ text: "Rename", iconCss: "e-icons e-rename", id: "rename" },
{ text: "Save as", iconCss: "e-icons e-save", id: "save" }
];
var ribbon = new ej.ribbon.Ribbon({
tabs: tabs,
fileMenu: {
menuItems: fileMenuItems,
visible: true
}
});
ribbon.appendTo("#ribbon");
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-ribbon/styles/material.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="ribbon"></div>
</div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Open submenu on click
You can open the submenu on menu item click, by setting the showItemOnClick property to true
. By default, the submenu will open on mouse hover.
var tabs = [
{
header: "Home",
groups: [
{
header: "Clipboard",
collections: [
{
items: [
{
type: "Button",
buttonSettings: {
content: "Paste",
iconCss: "e-icons e-paste",
}
},
],
},
{
items: [
{
type: "Button",
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut",
}
},
{
type: "Button",
buttonSettings: {
content: "Copy",
iconCss: "e-icons e-copy",
}
},
],
}
]
}
]
}
];
var fileMenuItems = [
{ text: "New", iconCss:"e-icons e-file-new", id: "new" },
{ text: "Open", iconCss:"e-icons e-folder-open", id: "open" },
{ text: "Rename", iconCss:"e-icons e-rename", id: "rename" },
{
text: "Save as",
iconCss:"e-icons e-save",
id: "save",
items: [
{ text: "Microsoft Word (.docx)" },
{ text: "Microsoft Word 97-2003(.doc)" },
{ text: "Download as PDF" }
]
}
];
var ribbon = new ej.ribbon.Ribbon({
tabs: tabs,
fileMenu: {
menuItems: fileMenuItems,
showItemOnClick: true,
visible: true
}
});
ribbon.appendTo("#ribbon");
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-ribbon/styles/material.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="ribbon"></div>
</div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
Custom header text
You can define the file menu header text content by using the text property.
var tabs = [
{
header: "Home",
groups: [
{
header: "Clipboard",
collections: [
{
items: [
{
type: "Button",
buttonSettings: {
content: "Paste",
iconCss: "e-icons e-paste",
}
},
],
},
{
items: [
{
type: "Button",
buttonSettings: {
content: "Cut",
iconCss: "e-icons e-cut",
}
},
{
type: "Button",
buttonSettings: {
content: "Copy",
iconCss: "e-icons e-copy",
}
},
],
}
]
}
]
}
];
var ribbon = new ej.ribbon.Ribbon({
tabs: tabs,
fileMenu: {
text: "App",
menuItems: [{ text: "New", iconCss: "e-icons e-file-new", id: "new" }],
visible: true
}
});
ribbon.appendTo("#ribbon");
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"></script>
<title>Essential JS 2 - Ribbon</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/29.2.4/ej2-ribbon/styles/material.css" rel="stylesheet">
<!--system js reference and configuration-->
<script src="https://cdn.syncfusion.com/ej2/29.2.4/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="ribbon"></div>
</div>
<script src="index.js" type="text/javascript"></script>
</body>
</html>