How to set SpreadContainer's height?

Posted by: priyatama.bhadke on 9 October 2023, 5:43 pm EST

  • Posted 9 October 2023, 5:43 pm EST

    Hi,

    How to set Spread Container’s Height? I tried below code but it did not work.

    var spreadContainer = document.getElementById(“ss”);

    var spreadheight = screen.height- screen.height*60/100;

    spreadContainer.style.height = spreadheight+“px”;

    Regards,

    Priya B

  • Posted 10 October 2023, 3:25 pm EST

    Hi,

    There are multiple ways by which you could set the spread height.

    1. You may use the getHost() and then apply the height of the host. Please refer to the following code snippet.
    spreadInstance.getHost().style.height = '800px';
    spreadInstance.refresh();
    1. You may also get the host element and change the higher after you just need to refresh the method.
    var spreadContainer = document.getElementById(“ss”);
    
    var spreadheight = screen.height- screen.height*60/100;
    
    spreadContainer.style.height = spreadheight+“px”;
    
    speadInstance.refresh();

    The key point here is you need to call the refresh the style of the host element gets changed. Use these suggestions and let me know if you face any issues.

    Regards,

    Avinash

  • Posted 11 October 2023, 5:36 pm EST

    Hi Avinash,

    1- spreadInstance.getHost().style.height = ‘800px’;

    spreadInstance.refresh(); → for this it gives error “spreadInstance” is not defined

    var spreadContainer = document.getElementById(“ss”);

    var spreadheight = screen.height- screen.height*60/100;

    spreadContainer.style.height = spreadheight+“px”;

    speadInstance.refresh(); → For this it gives error undefined for Spreadcontainer

    I should use document.getElementById(“ss”) or document.getElementById(“gc-designer-container”)

    Regards,

    Priya B

  • Posted 13 October 2023, 1:50 am EST

    Hi Priya,

    this is expected since your application does not declare the spread object named spreaInstance.n In place spreadInstance you need to use your spread object (Object of Workbook class).

    Regards,

    Avinash

  • Posted 15 October 2023, 4:18 pm EST

    Hi Avinash,

    I quiet did not understand what does it mean. spreadInstance you need to use your spread object (Object of Workbook class)

    can you please explain a bit more and if possible can you share any example to use object of spreadInstance ?

    Regards,

    Priya B

  • Posted 16 October 2023, 8:30 pm EST

    Hi Priya,

    Please refer to the following code snippet and attached sample that explains the same and let me know if you face any issues.

    
    let workbbookInstance = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
    
    document.querySelector('#change').addEventListener("click",()=>{
        workbbookInstance.getHost().style.height = '600px';
        workbbookInstance.refresh();
    
    })

    sample: https://jscodemine.grapecity.com/share/2JDB8ZJJJk6pkTjnKEwOLQ/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.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