diff --git a/apps/client/src/widgets/collections/table/index.tsx b/apps/client/src/widgets/collections/table/index.tsx index e9c8b8802..0fac94210 100644 --- a/apps/client/src/widgets/collections/table/index.tsx +++ b/apps/client/src/widgets/collections/table/index.tsx @@ -23,6 +23,7 @@ export default function TableView({ note, viewConfig, saveConfig }: ViewModeProp const [ maxDepth ] = useNoteLabelInt(note, "maxNestingDepth") ?? -1; const [ columnDefs, setColumnDefs ] = useState(); const [ rowData, setRowData ] = useState(); + const [ movableRows, setMovableRows ] = useState(); const tabulatorRef = useRef(null); const parentComponent = useContext(ParentComponent); @@ -38,6 +39,7 @@ export default function TableView({ note, viewConfig, saveConfig }: ViewModeProp }); setColumnDefs(columnDefs); setRowData(rowData); + setMovableRows(movableRows); }); }, [ note ]); @@ -58,6 +60,10 @@ export default function TableView({ note, viewConfig, saveConfig }: ViewModeProp footerElement={} events={contextMenuEvents} persistence {...persistenceProps} + layout="fitDataFill" + index="branchId" + movableColumns + movableRows={movableRows} /> diff --git a/apps/client/src/widgets/collections/table/tabulator.tsx b/apps/client/src/widgets/collections/table/tabulator.tsx index 4ed890aa9..2f8a00550 100644 --- a/apps/client/src/widgets/collections/table/tabulator.tsx +++ b/apps/client/src/widgets/collections/table/tabulator.tsx @@ -5,14 +5,13 @@ import "../../../../src/stylesheets/table.css"; import { ComponentChildren, RefObject } from "preact"; import { ParentComponent, renderReactWidget } from "../../react/react_utils"; -interface TableProps extends Pick { +interface TableProps extends Omit { tabulatorRef: RefObject; className?: string; - columns: ColumnDefinition[]; data?: T[]; modules?: (new (table: VanillaTabulator) => Module)[]; - footerElement?: ComponentChildren; events?: Partial; + index: keyof T; } export default function Tabulator({ className, columns, data, modules, tabulatorRef: externalTabulatorRef, footerElement, events, ...restProps }: TableProps) { @@ -34,7 +33,7 @@ export default function Tabulator({ className, columns, data, modules, tabula columns, data, footerElement: (parentComponent && footerElement ? renderReactWidget(parentComponent, footerElement)[0] : undefined), - ...restProps + ...restProps, }); tabulatorRef.current = tabulator; @@ -59,7 +58,7 @@ export default function Tabulator({ className, columns, data, modules, tabula }, Object.values(events ?? {})); // Change in data. - useEffect(() => { tabulatorRef.current?.setData(data) }, [ data ]); + useEffect(() => { console.log("Got data ", data); tabulatorRef.current?.setData(data) }, [ data ]); return (
diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 4383eada3..c93700740 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -61,14 +61,6 @@ export default class TableView extends ViewMode { const viewStorage = await this.viewStorage.restore(); this.persistentData = viewStorage?.tableData || {}; - let opts: Options = { - layout: "fitDataFill", - index: "branchId", - movableColumns: true, - movableRows, - footerElement: buildFooter(this.parentNote), - }; - if (hasChildren) { opts = { ...opts,