소스 검색

fix column resizing for `ui.aggrid` (fixes #2852)

Falko Schindler 1 년 전
부모
커밋
7abda3f3e7
1개의 변경된 파일4개의 추가작업 그리고 4개의 파일을 삭제
  1. 4 4
      nicegui/elements/aggrid.js

+ 4 - 4
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,