Ag-Grid - Row with multiline text
Asked Answered
N

1

13

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?

Numbers answered 17/3, 2016 at 18:21 Comment(1)
Do you not have the option to upgrade to a later version? getRowHeight is an available callback from version 3.1.2Redundant
F
2

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);
}
Fearless answered 17/3, 2016 at 21:37 Comment(1)
yes, I've tried but this function isn't available at version 1.16.1Luhe

© 2022 - 2024 — McMap. All rights reserved.