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

自闭症网瘾萝莉.ら 提交于 2020-07-09 04:11:13

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/49038923/ag-grid-how-to-insert-a-line-break-into-my-cell-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!