Disable sheet tab

Posted by: tovarnakm on 4 October 2021, 1:04 pm EST

    • Post Options:
    • Link

    Posted 4 October 2021, 1:04 pm EST

    Hello,

    I would like to ask, if SpreadJS supports functionality for disable to open some of sheet on tab click. I have implemented sheet permissions and I want to not allow

    not-permitted
    users see the content of sheet. But I want to leave restricted tabs visible. Can you help me please?

    Thank you for your answer

    Thank you for your answer!

  • Posted 5 October 2021, 6:52 am EST

    Hi,

    For this, You may use the mousedown event. Please refer to the following code snippet and let me know if you face any issues.

    
    document.getElementById("ss").addEventListener(
      "mousedown",
      function (e) {
        var y = e.pageY - this.offsetTop;
        var x = e.pageX - this.offsetLeft;
    
        var result = spread.hitTest(x, y);
        if (result && result.tabStripHitInfo && result.tabStripHitInfo.sheetTab) {
          if (result.tabStripHitInfo.sheetTab.sheetName === "Sheet2") {
            e.preventDefault();
            e.stopImmediatePropagation();
          }
        }
      },
      true
    );
    
    

    sample: https://codesandbox.io/s/spread-js-starter-forked-cgsw0?file=/src/index.js:795-1233

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels