From 7abda3f3e76df333ecdb4861dd58adc0a1bc93fe Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Mon, 13 May 2024 15:42:11 +0200 Subject: [PATCH] fix column resizing for `ui.aggrid` (fixes #2852) --- nicegui/elements/aggrid.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nicegui/elements/aggrid.js b/nicegui/elements/aggrid.js index 77722cdf4..5f5419ce3 100644 --- a/nicegui/elements/aggrid.js +++ b/nicegui/elements/aggrid.js @@ -8,10 +8,7 @@ export default { methods: { update_grid() { this.$el.textContent = ""; - this.gridOptions = { - ...this.options, - onGridReady: this.auto_size_columns ? (params) => params.api.sizeColumnsToFit() : undefined, - }; + this.gridOptions = { ...this.options }; for (const column of this.html_columns) { if (this.gridOptions.columnDefs[column].cellRenderer === undefined) { this.gridOptions.columnDefs[column].cellRenderer = (params) => (params.value ? params.value : ""); @@ -57,6 +54,9 @@ export default { return runMethod(this.gridOptions.api.getRowNode(row_id), name, args); }, handle_event(type, args) { + if ((type === "gridReady" || type === "gridSizeChanged") && this.auto_size_columns) { + this.gridOptions.api.sizeColumnsToFit(); + } this.$emit(type, { value: args.value, oldValue: args.oldValue,