Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to autosize the "auto group column"?

Tags:

ag-grid

How to auto resize all columns, including the auto group column ?

The following code only resizes standard columns and not the auto group column as this.gridColumnApi.getAllColumns() doesn't return the auto group column :

autoSizeAllColumns() {
  const allColumnIds = this.gridColumnApi.getAllColumns().map(c => c.colId)
  this.gridColumnApi.autoSizeColumns(allColumnIds)
},
like image 324
Thomas Avatar asked May 02 '19 08:05

Thomas


People also ask

How do you autosize all columns in Ag grid?

Auto-Size Columns Just like Excel, each column can be 'auto resized' by double clicking the right side of the header rather than dragging it. When you do this, the grid will work out the best width to fit the contents of the cells in the column.

How do you do a row grouping on Ag grid?

To group rows by a particular column, enable the rowGroup column property as shown below: const gridOptions = { columnDefs: [ { field: 'country', rowGroup: true, hide: true }, { field: 'year', rowGroup: true, hide: true }, { field: 'sport' }, { field: 'total' } ], // other grid options ... }

What is autoGroupColumnDef?

The Multiple Group Columns display type adds an Auto Group Column for each row group to the grid. To change the default configurations of these group columns, use the autoGroupColumnDef grid option as shown below: const autoGroupColumnDef = { headerValueGetter: params => `${params. colDef.


1 Answers

I was able to size and autosize the autogroup column directly by using the colID (which I learned is 'ag-Grid-AutoColumn').

To size it specifically:

onGridReady:function(params)
{
    params.columnApi.setColumnWidth('ag-Grid-AutoColumn', 250);
}

To autosize:

onFirstDataRendered:function(params)
{
    params.columnApi.autoSizeColumn('ag-Grid-AutoColumn');
}
like image 170
Herc Bontzolakes Avatar answered Oct 30 '22 01:10

Herc Bontzolakes