Luckysheet icon indicating copy to clipboard operation
Luckysheet copied to clipboard

[Feature request] Can Luckysheet generate an event in case of actual cell modification?

Open d01010101 opened this issue 2 years ago • 4 comments

Hi, it is just a question. How to detect that anything in the sheet has actually been modified? I need it for enabling the "Save" button in my app.

d01010101 avatar Apr 22 '22 10:04 d01010101

I've also been trying to detect cell updates. It'd be great to integrate Luchysheet into a webapp with state management. Did you find a way to do it @d01010101?

daalgi avatar Apr 25 '22 21:04 daalgi

Only this, somewhat crude: after a mouse/keyboard interaction with the sheet, test if getJson() changed.

d01010101 avatar Apr 25 '22 23:04 d01010101

I found an easier way to detect cell updates: using the hooks implemented in luckysheets. You can pass your code to be run in every cell update to the configuration object:

useEffect(() => {
    const sheet = window.luckysheet
    sheet.create({
        container: "luckysheet",
        title: "workbook",
        lang: 'en',
        data: data,
        hook: {
            updated: function (operate) {
                const r = operate.range[0].row[0]
                const c = operate.range[0].column[0]
                if (r === 0 && c === 0) {
                    setState({...state, x: operate.curdata[r][c].v})
                }
            }
        }
    })
}, [])

daalgi avatar May 01 '22 21:05 daalgi

The new version https://github.com/ruilisi/fortune-sheet seems to have callbacks.

d01010101 avatar May 19 '22 16:05 d01010101