How to expand particular sublevel of any level usingColumnOutlines in Spread JS

Posted by: pooja.bansal on 22 January 2021, 3:52 am EST

    • Post Options:
    • Link

    Posted 22 January 2021, 3:52 am EST - Updated 3 October 2022, 10:00 am EST

    Hi,

    Suppose we have following groups-

    Level 1 - Group 1

    Level 2 - Group 1, Group 2, Group 3, Group 4

    If we want to expand any of the level we are using below code -

    int level =1;

    var sheet = GC.Spread.Sheets.findControl(document.getElementById(‘test​’)).getActiveSheet();

    sheet.columnOutlines.expand((level -1)​​, true);

    sheet.invalidateLayout();

    sheet.repaint();

    It will expand Group 1 of level 1.

    This is working fine.

    Q1) If we want to expand particular group only at any level (like expand Group 2 only of level 2 or Group 2 and 3 only of level 2), how can we do it using above piece of code?

    Please refer attached image.

    Regards

    Pooja Bansal

  • Posted 25 January 2021, 4:01 am EST

    Hi Pooja,

    You may use the expandGroup method for the required functionality. Please refer to the following code snippet and attached sample that demonstrates the same.

    
      document.getElementById("hide").addEventListener("click", () => {
        sheet.suspendPaint();
        var rgi = sheet.rowOutlines.find(rowIndex, -1);
        if (rgi != null) {
         //path to the specific group
          sheet.rowOutlines.expandGroup(rgi.children[0].children[0], false);
        }
    
        sheet.invalidateLayout();
        sheet.resumePaint();
      });
    }
    
    

    Sample: https://codesandbox.io/s/awesome-banzai-lqzj0?file=/src/index.js:371-675

    API References:

    expandGroup: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Outlines.Outline~expandGroup.html

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels