Custom contextmenu

The following example customize the spreadsheet contextmenu removing the copy and paste options.



Source code

<html>
<script src="https://jspreadsheet.com/v7/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v7/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<script>
var data1 = [
    ['US', 'Cheese', '2019-02-12'],
    ['CA', 'Apples', '2019-03-01'],
    ['CA', 'Carrots', '2018-11-10'],
    ['BR', 'Oranges', '2019-01-12'],
];

mySpreadsheet = jspreadsheet(document.getElementById('spreadsheet'), {
    data: data1,
    columns: [
        { type: 'dropdown', url:'/jspreadsheet/countries', width:200, },
        { type: 'text', width:200, },
        { type: 'calendar', width:100, }
     ],
     allowComments: true,
     contextMenu: function(obj, x, y, e) {
         var items = [];

         if (x == null && y == null) {
             if (e.target.parentNode && e.target.tagName == 'DIV' && e.target.parentNode.classList.contains('jtabs-headers')) {
                 items.push({
                     title: obj.options.text.renameThisWorksheet,
                     onclick: function() {
                         var newName = prompt(obj.options.text.renameThisWorksheet, e.target.innerText);
                         if (newName) {
                             obj.renameWorksheet(e.target, newName);
                         }
                     }
                 });
             }
         } else {
             if (y == null) {
                 // Insert a new column
                 if (obj.options.allowInsertColumn == true) {
                     items.push({
                         title:obj.options.text.insertANewColumnBefore,
                         onclick:function() {
                             obj.insertColumn(1, parseInt(x), 1);
                         }
                     });
                 }

                 if (obj.options.allowInsertColumn == true) {
                     items.push({
                         title:obj.options.text.insertANewColumnAfter,
                         onclick:function() {
                             obj.insertColumn(1, parseInt(x), 0);
                         }
                     });
                 }
             } else {
                 // Insert new row
                 if (obj.options.allowInsertRow == true) {
                     items.push({
                         title:obj.options.text.insertANewRowBefore,
                         onclick:function() {
                             obj.insertRow(1, parseInt(y), 1);
                         }
                     });

                     items.push({
                         title:obj.options.text.insertANewRowAfter,
                         onclick:function() {
                             obj.insertRow(1, parseInt(y));
                         }
                     });
                 }
             }

             // Line
             items.push({ type:'line' });

             // Save
             if (obj.options.allowExport) {
                 items.push({
                     title: obj.options.text.saveAs,
                     shortcut: 'Ctrl + S',
                     onclick: function () {
                         obj.download();
                     }
                 });
             }

             // About
             if (obj.options.about) {
                 items.push({
                     title:obj.options.text.about,
                     onclick:function() {
                         alert(obj.options.about);
                     }
                 });
             }
         }

         return items;
     },
     license: 'ZjJmODdjOTc3NjI0OWZmNTllMGUzMDczMmJiNGY5YmM1Y2IzYzYwZDU3Y2M4MDkxODczYTEwMDJiNmJmMDY3NWU3M2E1YTFiMzc2MDMyYTkyNjE5MmE4YTdjMjZlYTVhNjA2MTYwZDA1ZWJkYjE3MzFmMTAyMDY2NTdjYzkxNGIsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UWTVOalE1TnpVd01pd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owSWl3aVltRnlJaXdpZG1Gc2FXUmhkR2x2Ym5NaUxDSnpaV0Z5WTJnaUxDSndjbWx1ZENJc0luTm9aV1YwY3lKZExDSmtaVzF2SWpwMGNuVmxmUT09',
});
</script>
</html>