本文介绍了AgGrid 多行单元格内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用此解决方案,但它对我不起作用,它正确调整列高大小,但文本未换行.,它说你需要添加一些css来使文字换行.因此,在受影响列的 colDef 中(如果我遵循正确,则为 zaglavie)添加 cellStyle: {'white-space': 'normal'}.这是演示的 plnkr.

I tried to use this solution, but it does not work for me, Its correct resize column height, but text is not wrapped.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;
}
解决方案

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.

这篇关于AgGrid 多行单元格内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-31 13:27