Ag-Grid - Row with multiline text

為{幸葍}努か 提交于 2019-12-08 15:16:47

问题


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.

I've tried:

  • sizeColumnsToFit method, expecting that ag-grid could resize column by its content;

  • setRowStyle method at gridOptions: I've added CSS classes to adjust roe height by the content (e.g: 'word-wrap':'break-word');

  • minWidth and width: I've calculated the average column size but ag-grid didn't respect it;

  • cellStyle at gridOptions: on the same way as "setRowStyle", but CSS classes didn't gave me any success;

Does anyone has another suggestion?


回答1:


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);
}


来源:https://stackoverflow.com/questions/36068743/ag-grid-row-with-multiline-text

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