当我在 columnDefs 中有 2 列时,如何设置列以占用完整的 ag-grid 宽度?

How can I set columns to take full ag-grid width when I have 2 columns in columnDefs?

我正在动态构建 columnDef,它有时包含 2 列或多于 2 列。 我想要 2 列占据 ng-grid 的全宽。我试过 autoSizeColumns 但它不起作用,2 列没有占据 ag-grid 的整个宽度。

columnDefs = [
  {
    "headerName": "Term/KMs",
    "field": "termkms",
    "sortable": false,
    "filter": false,
    "lockPosition": true,
    "cellRenderer:" "asteriskCellRendererFunc(params)"
    "cellStyle": {
      "color": "#fff",
      "text-align": "center",
      "background-color": "#4a5568",
      "font-size": "1rem",
      "padding-left": ".5rem",
      "padding-right": ".5rem",
      "padding-top": ".5rem",
      "padding-bottom": ".5rem",
      "font-weight": "700",
      "border-width": "1px",
      "border-color": "#cbd5e0"
    },
    "resizable": true
  },
  {
    "headerName": "250,000 kms",
    "field": "250,000",
    "sortable": true,
    "filter": true,
    "resizable": true
  }
]
<ag-grid-angular
        #agGrid
        id="myGrid"
        style="width: 100%;"
        class="ag-theme-alpine"
        [rowHeight]="70"
        [rowData]="this.rowData"
        [columnDefs]="this.columnDefs"
        (cellClicked)="onCellClicked($event)"
        domLayout='autoHeight'
        (firstDataRendered)="onFirstDataRendered($event)"
      >
      </ag-grid-angular>

使用Column Flex:

例如

<ag-grid-angular
    // [...]
    [defaultColDef]="defaultColDef"
    >
</ag-grid-angular>
defaultColDef = {
    flex:1,
    minWidth:100
}