Console error after creating new blank file

Posted by: wojciech.tartanus on 7 January 2021, 11:30 pm EST

  • Posted 7 January 2021, 11:30 pm EST

    After creating a new blank file from File tab I'm getting error in the console.
    Uncaught TypeError: Cannot read property 'calcOnDemand' of null this error is also shown on click outside the spreadsheet.
  • Replied 10 January 2021, 9:00 pm EST

    Hi Wojtek,

    We are unable to replicate the issue at our end. Could you please let us know on which version are you facing this issue? also if possible please provide a small sample that replicates the issue so that we could investigate it further and assist you accordingly. You may also check the designer v14 sample and let us know if we have missed anything to replicate the issue.

    Designer v14 Sample: https://codesandbox.io/s/spread-js-starter-forked-0cg1o?file=/src/index.js

    Regards
    Avinash
  • Replied 10 January 2021, 10:07 pm EST

    Hi Avinash,

    Mine apologizes I bit hurred up with creating this ticket. I will try to explain it better. We are using version 14 with React component. We implemented in the way:


    const [spreadInstance, setSpreadInstance] = useState();

    const initSpread({ spread }) => {
    setSpreadInstance(spread);
    }

    <Designer
    designerInitialized={initSpread}
    />


    Also, we implemented autosave on click outside the spreadsheet. To save data we are using spreadInstance..toJSON(). All of that is working fine for almost every scenario. In case when is created a new blank file calling spreadInstance..toJSON() is causing above error. Quite possible that spreadInstance which we are holding is destroyed instance. Could you point me to an event in which I can get an instance of newly created GC.Spread.Sheets.Workbook or method which will return the current instance.
  • Replied 11 January 2021, 7:13 pm EST

    Hi Avinash,

    I have found 2 solutions for my issues.
    1. I can pas ref to <Designer />, then I have constant access to current Spread instance
    2. During initialization instead of keeping a reference to Spread instance I keep a reference to the whole object which is passed by <Designer /> after init, and then I have always actual Spread instance.

    I'm not sure if is intentional but while looking for a way to get current spread instance I found that is possible to use GC.Spread.Sheets.findControl(document.getElementById(#hostid)
    which unfortunately isn't working when is used <Designer /> React component.

    Thank you very much for taking the time to help me :)

    Kind Regards,
    Wojtek
  • Replied 11 January 2021, 7:34 pm EST

    Hi Wojtek,

    You may also use the designer.getWorkbook() method for the required functionality. further, findControl could not be used in frameworks such as angular and React.


    workbookInitialized = (e) => {

    designer = e.designer;
    currentWorkbook = designer.getWorkbook()
    };
    <Designer designerInitialized={workbookInitialized} />


    Regards
    Avinash
Need extra support?

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

Learn More

Forum Channels