Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ag-grid renders extra blank column right to the last column

I use ag-grid with Angular 1.5 and I have defined 5 columns in the following format in an array:

[
{headerName: 'Username', width: 150, field: 'username'},
{headerName: 'Full Name', width: 150, field: 'full_name'},
{headerName: 'Location', width: 150, field: 'location'},
{headerName: 'Email', width: 150, field: 'email'},
{headerName: 'Check In Comment', width: 370, field: 'comment'},
];

The rendering shows 6 columns with the right-most one being blank. I've tried everything, but I cannot still remove the blank column. See the below screenshot:

gridOptions:

options = {
                rowData: dataArray,
                rowModelType: 'pagination',
                columnDefs: getColumnDefs(),
                enableColResize: true,
                enableSorting: false,
                enableFilter: true,
                rowHeight: 25,
                angularCompileRows: true,
                suppressRowClickSelection: true
            };

The html code:

<div style="width: 100%;"
                     ag-grid="vm.gridOptions"
                     class="ag-fresh ag-basic">
                </div>

I wonder how to remove the blank column right to the 'Check In Comment' column. any ideas?

like image 416
TonyGW Avatar asked May 10 '16 18:05

TonyGW


People also ask

How do you set column width dynamically in Ag grid?

Turn column resizing on for the grid by setting resizable=true for each column. To set resizing for each column, set resizable=true on the default column definition. The snippet below allows all columns except Address to be resized by explicitly setting each column.

How do you fit columns on Ag grid?

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. The grid works out the best width by considering the virtually rendered rows only.

What is flex in Ag grid?

Flex sizing works by dividing the remaining space in the grid among all flex columns in proportion to their flex value. For example, suppose the grid has a total width of 450px and it has three columns: the first with width: 150 ; the second with flex: 1 ; and third with flex: 2 .


Video Answer


2 Answers

Have you tried gridOptions.api.sizeColumnsToFit() ?

Source (7min 50sec)

like image 163
BabarConnect Avatar answered Nov 15 '22 02:11

BabarConnect


extra column is there even if we use that api gridOptions.api.sizeColumnsToFit().

image

like image 43
rajgopalK Avatar answered Nov 15 '22 02:11

rajgopalK