Skip to main content Skip to footer

Remove SpreadJS Context Menu Items

To modify the default items in the SpreadJS context menu, we can edit the spread.contextMenu.menuData array. This will allow us to remove default actions, such as “Copy”. The following code shows an example on how we could do this:

var contextMenu = spread.contextMenu.menuData;
    //Declare which item (by text) to look for. “item.name” could also be used instead. 
    const index_copy = contextMenu.findIndex((item: { text: string; }) => item.text === "Copy");

    if (index_copy !== -1) {
      // If the object is found, use splice to remove it
      contextMenu.splice(index_copy, 1);
    }

This results in the following context menu, with "Copy" being removed:

Tye Glenz