Disable Delete sheet button based on condition

Posted by: sharaththota.zem on 22 November 2022, 10:23 pm EST

  • Posted 22 November 2022, 10:23 pm EST - Updated 22 November 2022, 10:29 pm EST

    Hi Team

    i want to disable the delete sheet button in the context menu ,if number of worksheets are only one.

  • Posted 23 November 2022, 4:20 am EST

    Hi,

    For this, you need to add disable property to delete the Sheet Item from the Context menu. Please refer to the following code snippet and the attached sample that implements the same.

    function setVisibleForDeleteSheet(spread, value) {
      spread.contextMenu.menuData.forEach((el) => {
        if (el.name === "gc.spread.deleteSheet") {
          el.disable = value;
        }
      });
    }

    sample: https://codesandbox.io/s/great-bush-lvq5qq?file=/src/index.js:780-786

    Regards,

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels