I have an ag-grid (in javascript) that sometimes can have many columns, and others just a few (and they have different contets/sizes). I’d like to have an auto-size that fits at least the content (so, the columns can occupy a larger width than the grid size, with horizontal scrolling), but if there are only few columns, they’d stretch to fill the whole grid. The autoSizeStrategy
type: 'fitCellContents'
fit the contents, but when I have few columns, it does not occupy the whole grid. On the other hand, type: 'fitGridWidth'
sometimes make the cells smaller than the contents. Is there a way to achieve both?
PS: I have flex: 1,
in the defaultColDef
and I’m using the CSS (mainly due to some alignments issues and to display ellipsis for large contents):
.ag-cell {
height: 100%;
width: 100%;
padding: 0 2px;
text-overflow: ellipsis;
overflow: hidden;
}
.ag-cell-wrapper {
text-align: inherit;
vertical-align: middle;
}
I guess this may affect the behaviour I’m trying to achieve.