import React from "react"; import { type DataEditorRef } from "../../data-editor/data-editor.js"; import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; import { BeautifulWrapper, Description, MoreInfo, PropName, useMockDataGenerator, KeyName, defaultProps, clearCell, } from "../../data-editor/stories/utils.js"; import { SimpleThemeWrapper } from "../../stories/story-utils.js"; export default { title: "Glide-Data-Grid/DataEditor Demos", decorators: [ (Story: React.ComponentType) => ( ), ], }; export const AppendRowHandle: React.VFC = () => { const { cols, getCellContent, setCellValueRaw, setCellValue } = useMockDataGenerator(60, false); const [numRows, setNumRows] = React.useState(50); const ref = React.useRef(null); const onClick = React.useCallback(() => { void ref.current?.appendRow(3, false); }, [ref]); const onRowAppended = React.useCallback(() => { const newRow = numRows; for (let c = 0; c < 6; c++) { const cell = getCellContent([c, newRow]); setCellValueRaw([c, newRow], clearCell(cell)); } setNumRows(cv => cv + 1); }, [getCellContent, numRows, setCellValueRaw]); return ( Adding data can also be triggered from outside of DataEditor By calling appendRow on a ref to your grid, you can trigger the append elsewhere, like this Append button }> ); };