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/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v7/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v4/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: 'ZmY5N2Q1OTMyMzQ3MjgxMzJlMmI5MmFkY2FmMmNhNzVlOGU3ZjI4MWFjYmUxNDMzZjA2ZjhkOWVlZTRjNTMyOWVjZjdjYjU4YTY1YTNmY2ZkYjU4NDc3NzA2MTI1OWI2OTMzNWZkNTNkMDAyZDI4ZDNlMGIxMDI3MDAyMjRiY2EsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UWTJORFF5TWpZNU15d2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWJHOWpZV3hvYjNOMElsMHNJbkJzWVc0aU9pSXpJaXdpYzJOdmNHVWlPbHNpZGpjaUxDSjJPQ0lzSW5ZNUlpd2lZMmhoY25Seklpd2labTl5YlhNaUxDSm1iM0p0ZFd4aElpd2ljR0Z5YzJWeUlpd2ljbVZ1WkdWeUlpd2lZMjl0YldWdWRITWlMQ0pwYlhCdmNuUWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0pkTENKa1pXMXZJanAwY25WbGZRPT0=',
});
</script>
</html>