I have the following ag-grid
configurations. Somehow every column I have does not fit even after executing this.gridApi.sizeColumnsToFit()
. Most importantly, I cannot give width to each columns since it gets dynamically loaded from server and every time a file loads I might have dynamic range of columns.
How can I fit the column width for every column in the grid?
<div id="mygrid" className="ag-theme-alpine" style={{ width: '100%', height: 720 }}>
<AgGridReact
columnDefs={this.state.columnDefs}
defaultColDef={{ resizable: true }}
rowData={this.state.rowData}
onGridReady={this.onGridReady.bind(this)}
onCellValueChanged={this.onCellValueChanged}
/>
</div>
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.gridApi.sizeColumnsToFit();
}