mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 00:08:52 -06:00
web: Fix update columns
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user