import React from "react"; import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; import { BeautifulWrapper, Description, useMockDataGenerator, 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) => ( Rows can be frozen to make sure the user always sees them. }> ), ], }; export const FreezeRows: React.VFC = () => { const { cols, getCellContent, setCellValueRaw, setCellValue } = useMockDataGenerator(60, false); const [numRows, setNumRows] = React.useState(50); const onRowAppended = React.useCallback(() => { const newRow = numRows; // our data source is a mock source that pre-fills data, so we are just clearing this here. You should not // need to do this. for (let c = 0; c < cols.length; c++) { const cell = getCellContent([c, newRow]); setCellValueRaw([c, newRow], clearCell(cell)); } // Tell the data grid there is another row setNumRows(cv => cv + 1); }, [cols.length, getCellContent, numRows, setCellValueRaw]); return ( ); };