how to avoid whitespace on right side if columns are less in Ag grid

Viewed 1120

The answer might be sizeTofit . But When I have to resize the column then that whitespace is coming on the right side of the grid.

So I need to do the last column of the grid to occupy the grid fully if columns are less (Or if I remove come column)otherwise it will take the column width provided by the property to Ag grid

This is the image I am getting now

This is the image I am getting now

like this I want

like this I want

1 Answers

if size of it is not what you want then you can write a function and do the calculations manually.

set the width of columns and at the end set new column defs to your ag grid;

var tableWidth = sth;
var totalWidth = 0;
for(var i = 0; i<columnDefs.length; i++) {
    totalWidth += columnDefs[i].width;
    if((i == columnDefs.length - 1) && (totalWidth < tableWidth)) {
        columnDefs[i] += tableWidth - totalWidth;
    }
}
api.setColumnDefs(columnDefs);
Related