Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AG-Grid - How to insert a line break into my cell data

I'm new to AG-Grid, so forgive me if this is a dumb question. We're using the OSS version of Ag-Grid in an Angular 5 application. I have a column where I am combining two sets of summary data and showing them. I would like to have a line-break between the two pieces of text.

Right now it's doing this:

"Summary One Summary Two"

I want it to do this:

"Summary One
Summary Two"

So far I've tried and HTML break tag, \r\n and just \n and nothing has worked. Is this possible to do?

Thanks, James

like image 604
James Bender Avatar asked Feb 28 '18 21:02

James Bender


1 Answers

You can use cellRenderer to achieve this.

Have a look at below colDef.

{
  headerName: "Custom column", 
  cellRenderer: function(param){
    return param.data.col1 + '<br/>' + param.data.col2;
  }
}

You might need to set rowHeight in gridOptions as well.

Live example: Plunk

like image 187
Paritosh Avatar answered Nov 15 '22 16:11

Paritosh