Posted 28 May 2019, 1:50 pm EST
Hi,
How do I instantiate FormulaTextBox in a React app? I can’t seem to find a support article on this.
Daniel
Forums Home / Spread / SpreadJS
Posted by: daniel on 28 May 2019, 1:50 pm EST
Posted 28 May 2019, 1:50 pm EST
Hi,
How do I instantiate FormulaTextBox in a React app? I can’t seem to find a support article on this.
Daniel
Posted 29 May 2019, 2:47 am EST
Hi,
You could use the react refs to get the reference to the dom element and then pass it the FormulaTextBox constructor. Please refer to the following code snippet and the attached sample demonstrating the same:
initWorkSheet = (spread) => {
/* create formula box */
let fbx = new GC.Spread.Sheets.FormulaTextBox.FormulaTextBox(this.fbRef.current);
fbx.workbook(spread);
}
render(){
return(
<div style={{width: '100%',height: '600px'}}>
<div style={{border: "1px solid gray"}} ref={this.fbRef} contentEditable={true} spellCheck={false}></div>
<SpreadSheets workbookInitialized={this.initWorkSheet}>
<Worksheet />
</SpreadSheets>
</div>
)
}
~sharad
spreadReactFormulaBox.zip
Posted 29 May 2019, 10:28 am EST
Thanks Sharad! A great answer as always!