Ag-grid multiline cell content

Axixa picture Axixa · Apr 6, 2017 · Viewed 24.4k times · Source

I tried to use this solution, but it does not work for me, Its correct resize column height, but text is not wrapeed. Ag-Grid - Row with multiline text

    var gridOptions = {
    columnDefs: columnDefs,
    rowSelection: 'multiple',
    enableColResize: true,
    enableSorting: true,
    enableFilter: true,
    enableRangeSelection: true,
    suppressRowClickSelection: true,
    animateRows: true,
    onModelUpdated: modelUpdated,
    debug: true,
    autoSizeColumns:true,
    getRowHeight: function(params) {
        // assuming 50 characters per line, working how how many lines we need
        return 18 * (Math.floor(params.data.zaglavie.length / 45) + 1);
    }
};

function createRowData() {

    return gon.books;
}

enter image description here

Answer

Jarod Moser picture Jarod Moser · Apr 12, 2017

If you follow the "Row Height More Complex Example" found on the Docs, it says that you need to add some css to make the words wrap. So in your colDef for your affected column (zaglavie if I follow correctly) add cellStyle: {'white-space': 'normal'}. Here's a plnkr that demonstrates.