Posted 2 March 2023, 5:07 pm EST
I thought I would describe my case thoroughly because the title wouldn’t explain enough.
Currently, we block users from entering text into a cell with a default formula like this:
GC.Spread.Sheets.CellTypes.Text.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
const { sheet, row, col } = context
speadJsHelper.registerSingleEventListener(editorContext, htmlDomEventNames.keydown, (event) => {
if (!event.ctrlKey && //for allowing ctr action such as paste
!spreadJSHelper.isValidKeyCodeForNumericInput(event, event.key, separator) || // for validate key press
(event.target.innerText.includes(separator) && event.key == separator) || // for one separator validation
(event.target.innerText.includes(keyCodesString.MINUS_SIGN) && event.key == keyCodesString.MINUS_SIGN) || // for one minus-sign validation
!sapTestingSheetSpeadJsHelper.isValidDecimalPatternFormatAtKeyPress(event, separator, lastedKeyPressed) // custom validate follow format decimal(18,2)
) {
event.preventDefault()
}
})
}
It works and prevents the user enter text into the cell.
The problem is that when the user cannot enter text in that cell and they click on another cell, the default formula in the cell is lost. I think this is the design of SpreadJS like Excel.
May I ask is there a way for the user to click on another cell and still keep the formula? Like pressing the ESC key
Regards,
Thanh