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

rvpgvaaj  于 2022-10-28  发布在  其他
关注(0)|答案(4)|浏览(268)

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.

eit6fx6z

eit6fx6z1#

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?

ut6juiuv

ut6juiuv2#

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

vohkndzv

vohkndzv3#

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})
                }
            }
        }
    })
}, [])

相关问题