Posted 7 January 2021, 11:30 pm EST - Updated 3 October 2022, 1:01 am EST
Console error after creating new blank file
Posted by: wojciech.tartanus on 7 January 2021, 11:30 pm EST
-
-
Posted 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 -
Posted 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.
-
Posted 11 January 2021, 7:13 pm EST
Hi Avinash,
I have found 2 solutions for my issues.
- I can pas ref to , then I have constant access to current Spread instance
- During initialization instead of keeping a reference to Spread instance I keep a reference to the whole object which is passed by 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 React component.Thank you very much for taking the time to help me
Kind Regards,
Wojtek -
Posted 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