Ag-Grid-多行文本行 [英] Ag-Grid - Row with multiline text
问题描述
我正在使用 Angular Grid (1.16.1版),我需要显示一个较长的表格中的文本,我希望行高可以根据内容进行调整,必要时可以换行。
I'm using Angular Grid (version 1.16.1) and I need to show a long text inside a table and I want that row height would be adjusted by the content, breaking line if necessary.
我尝试过:
-
sizeColumnsToFit方法,希望ag-grid可以根据其内容调整列的大小;
sizeColumnsToFit method, expecting that ag-grid could resize column by its content;
gridOptions的setRowStyle方法:我添加了CSS类以通过内容调整鱼卵高度(例如:'word-wrap':'break-word');
setRowStyle method at gridOptions: I've added CSS classes to adjust roe height by the content (e.g: 'word-wrap':'break-word');
minWidth和width:我已经计算出平均列大小,但是ag-grid不尊重它;
minWidth and width: I've calculated the average column size but ag-grid didn't respect it;
有人有其他建议吗?
推荐答案
我在没有运气的情况下使用CSS进行了尝试,您是否研究了动态行高?在此处查看示例: https://www.ag-grid。 com / angular-grid-row-height / index.php 。它使用文本的长度来计算每一行的高度。以下是示例的摘要:
I have tried it with css with no luck, have you looked into dynamic row height? See an example here: https://www.ag-grid.com/angular-grid-row-height/index.php. It using the length of the text to calculate the height of each row. Here's a snippet from the example:
getRowHeight: function(params) {
// assuming 50 characters per line, working how how many lines we need
return 18 * (Math.floor(params.data.latinText.length / 45) + 1);
}
这篇关于Ag-Grid-多行文本行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!