sparsh610
sparsh610

Reputation: 1601

ag-grid : setting rowHeight manually

I am trying to set the row height of ag-grid like below

<ag-grid-angular  style="height: 130px;"  [rowData]="rows"  [columnDefs]="columns" [getRowHeight]="getRowHeight">

and in ts file

getRowHeight = 5;

I also changed it to 5px but it is not reflecting. any other way to do the same.

I am doing it in angular8

I also added the snapshot it looks like after I made it 20px enter image description here

Upvotes: 0

Views: 2351

Answers (1)

Anton Sarov
Anton Sarov

Reputation: 3748

getRowHeight is the callback function but why can't you just use the property rowHeight on the grid object itself. Like this:

<ag-grid-angular  style="height: 130px;"  [rowData]="rows"  [columnDefs]="columns" [rowHeight]="rowHeight">

And then in your component:

rowHeight = 5

Edit 1:

You can also set autoheight for your rows - then the row height will be adapted according to the provided data:

In your template: <ag-grid-angular [defaultColDef]="defaultColDef" ...(all the other options)... > In your component:

this.defaultColDef = {
      flex: 1,
      autoHeight: true,
};

The default value is 25 (pixels)

Upvotes: 2

Related Questions