AG-Grid-如何在单元格数据中插入换行符 [英] AG-Grid - How to insert a line break into my cell data

查看:1021
本文介绍了AG-Grid-如何在单元格数据中插入换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AG-Grid的新手,如果这是一个愚蠢的问题,请原谅我。我们正在Angular 5应用程序中使用OSS版本的Ag-Grid。我有一列将两个汇总数据组合在一起并显示它们。我想在这两段文字之间使用换行符。

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.

现在它正在这样做:

摘要一摘要二

我希望它这样做:

摘要一

摘要二

"Summary One
Summary Two"

到目前为止,我已经尝试过HTML中断标记\r\n和\n,但没有任何效果。

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

谢谢,
James

Thanks, James

推荐答案

您可以使用 cellRenderer 来实现这一目标。

You can use cellRenderer to achieve this.

请查看下面的 colDef

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

您可能需要设置 gridOptions 中的rowHeight

You might need to set rowHeight in gridOptions as well.

实时示例:插件

这篇关于AG-Grid-如何在单元格数据中插入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆