Before ag-grid v11.0, sizeColumnsToFit() fired with an event that did not pass the parameter 'finished=true'. When a user manually resized a column, the event would pass 'finished=true' once the resize drag was complete. This allowed me to distinguish between a manual and automatic column resize.
As of ag-grid v11.0, sizeColumnsToFit() now fires an event with parameter 'finished=true'. Is there any way to distinguish between this automatic resize and a manual user resize?
Select the column (s) that you want to fit to the text inside them Right click at the top of a selected column, then click "Resize column…" Click "Fit to data, then click, "OK"
To automatically resize column width in Google Sheets to fit text, follow these steps: 1 Select the column (s) that you want to fit to the text inside them 2 Right click at the top of a selected column, then click "Resize column…" 3 Click "Fit to data, then click, "OK" More items...
Right-click at the top of any of the select columns, click "Resize columns", select "Fit to data", and then click "OK" Or, if you want, you can use the "Fit to data" shortcut, by double-clicking on the barrier between any two of the selected columns (at the top of the columns)
Note that some of the columns are wider than others, due to the varying text length in each cell in row 1. Column A has expanded to fit the longest name in that column, as the longest name is longer than the text that is in the header for that particular column.
The ColumnEvent, from which the ColumnResizedEvent is derived has a "source" property that reads "sizeColumnsToFit" or "uiColumnDragged" and even "autosizeColumns" when a you double click the partition.
https://www.ag-grid.com/javascript-grid-events/#properties-and-hierarchy
You should be able to use the source to determine how the event was fired.
myEventHandler(ev: ColumnResizedEvent) {
if (ev.source === 'sizeColumnsToFit') {
do.this;
} else {
do.that;
}
}
when you drag the column manually, source is always "uiColumnDragged"
if (event.source === 'uiColumnDragged') {
// your logic here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With