From 771eb5fa6ddffa1e592049e33fe37d3bd9f7a166 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Tue, 9 Sep 2025 10:18:51 -0500 Subject: [PATCH] web: Fix update columns --- web/src/components/Common/Forms/DataTable.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/src/components/Common/Forms/DataTable.tsx b/web/src/components/Common/Forms/DataTable.tsx index b9f3306..571d86e 100644 --- a/web/src/components/Common/Forms/DataTable.tsx +++ b/web/src/components/Common/Forms/DataTable.tsx @@ -396,6 +396,7 @@ const DataTable = (props: DataTableProps) => { const height = computeTableHeight(data); if (tableRef.current === null) { + console.log("new Tabulator"); tableRef.current = new Tabulator(tableContainerRef.current, { layout: "fitColumns", data: data, @@ -416,8 +417,16 @@ const DataTable = (props: DataTableProps) => { tableRef.current.replaceData(newData).then(() => {}); // Update columns - if (newColumns.length !== tableRef.current.getColumns().length) { + let newColCount = 0; + newColumns.forEach((col) => { + if (col.columns) newColCount += col.columns.length; + else newColCount += 1; + }); + if (newColCount !== tableRef.current.getColumns().length) { tableRef.current.setColumns(newColumns); + const rows = tableRef.current!.getRows()!; + const firstRow = rows[0]; + if (firstRow) firstRow.scrollTo().then((r) => {}); } // Update height