From 5b8c4bc8666ec9aadc7b96e5a5cd934e5b66578f Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Tue, 19 Jan 2021 11:24:58 -0500 Subject: [PATCH] Pack event table columns on first model update Signed-off-by: Patrick Tasse --- .../src/components/table-output-component.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-components/src/components/table-output-component.tsx b/packages/react-components/src/components/table-output-component.tsx index de458398c..7bf842907 100644 --- a/packages/react-components/src/components/table-output-component.tsx +++ b/packages/react-components/src/components/table-output-component.tsx @@ -2,7 +2,7 @@ import { AbstractOutputComponent, AbstractOutputProps, AbstractOutputState } from './abstract-output-component'; import * as React from 'react'; import { AgGridReact } from 'ag-grid-react'; -import { ColDef, IDatasource, GridReadyEvent, CellClickedEvent, GridApi } from 'ag-grid-community'; +import { ColDef, IDatasource, GridReadyEvent, CellClickedEvent, GridApi, ColumnApi } from 'ag-grid-community'; import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper'; import { cloneDeep } from 'lodash'; import { signalManager } from '@trace-viewer/base/lib/signal-manager'; @@ -29,8 +29,10 @@ export class TableOutputComponent extends AbstractOutputComponent = { cacheBlockSize: 200, @@ -54,7 +56,6 @@ export class TableOutputComponent extends AbstractOutputComponent { this.handleTimeSelectionChange(range); }); this.onEventClick = this.onEventClick.bind(this); this.onModelUpdated = this.onModelUpdated.bind(this); } @@ -140,6 +141,7 @@ export class TableOutputComponent extends AbstractOutputComponent { this.gridApi = event.api; + this.columnApi = event.columnApi; const dataSource: IDatasource = { getRows: async params => { if (this.fetchColumns) { @@ -244,11 +246,15 @@ export class TableOutputComponent extends AbstractOutputComponent { - if (this.pendingIndex && this.gridApi) { + if (this.pendingIndex && this.gridApi) { if (this.gridApi.getSelectedNodes().length === 0) { this.gridApi.getDisplayedRowAtIndex(this.pendingIndex).setSelected(true); } this.pendingIndex = undefined; - } + } + if (this.columnArray.length > 0 && !this.columnsPacked && this.columnApi) { + this.columnApi.autoSizeAllColumns(); + this.columnsPacked = true; + } }; }