TabStrip ContextMenu insert

Posted by: razeris563 on 9 September 2021, 3:07 am EST

    • Post Options:
    • Link

    Posted 9 September 2021, 3:07 am EST - Updated 3 October 2022, 9:38 am EST

    Greetings, I would like to ask about changing the position of inserted tab in the TabStrip bar. Currently if I insert it with the usage of context menu and built in “insert”, it puts the new tab before the one i was on previously. Is it possible to change this behavior and put it AFTER it instead?

  • Posted 10 September 2021, 6:05 am EST

    Hi,

    For this, you may create your own insert sheet command. Please refer to the following code snippet and attached sample that demonstrates the same.

    
      var insertSheetItem = {
        text: "Insert Sheet",
        name: "customInsertSheet",
        command: insertSheet,
        workArea: "sheetTab"
      };
      spread.contextMenu.menuData.push(insertSheetItem);
      spread.contextMenu.menuData.forEach((menuItem, index) => {
        if (menuItem.name === "gc.spread.insertSheet") {
          spread.contextMenu.menuData.splice(index, 1);
        }
      });
      function insertSheet() {
        let sheetIndex = spread.getActiveSheetIndex();
        let sheetName = "Sheet" + (spread.getSheetCount() + 1);
        spread.addSheet(sheetIndex + 1, new GC.Spread.Sheets.Worksheet(sheetName));
        spread.setActiveSheetIndex(sheetIndex + 1);
      }
    
    

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

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels