javascriptangularag-gridag-grid-reactag-grid-ng2

Angular ag-grid resize issue


I want to enable column resizing but in the same time I want to avoid the case when the user resize any column to the left side of the grid and doing this a blank space appers on the right of the last column. I attached a picture below to explain what I'm trying to achieve.

enter image description here


Solution

  • Something like this should do for you. Main point is to listen for the columnResized event, then check if the current column size total is larger than the grid width, if so then use the sizeColumnsToFit function. Be careful with this though; the sizeColumnsToFit function will try to maintain ratios of the columns, so perhaps you would prefer to size all the columns to 10px, then size to fit. It mostly depends on your use case and how you want it to behave.