简体   繁体   English

使用自定义 cellRenderer 时,Ag Grid autoHeight 和 wrapText 不起作用

[英]Ag Grid autoHeight and wrapText not working when using custom cellRenderer

I'm trying to wrap the text of lengthy cell value.我正在尝试wrap the text As per documentation setting autoHeight=true and wrapText=true working fine without cellRenderer components.根据文档设置autoHeight=truewrapText=true在没有cellRenderer组件的情况下工作正常。 But when using cellRendererFramework React component, seems not working .但是当使用cellRendererFramework React component, seems not working I tried to setting style inside custom cell renderer also not working.我试图在自定义单元格渲染器中设置样式也不起作用。 Any help would be greatly appreciated!任何帮助将不胜感激!

AgGrid component is as below, AgGrid 组件如下,

<AgGridReact
    {...configs}
    onGridReady={onGridReady}
    masterDetail={true}
    suppressContextMenu
    detailCellRenderer='agCustomDetailTimelineRenderer'
    detailRowHeight={140}
    frameworkComponents={{
        agCustomRenderer: CustomRenderer,
    }}>
    {configs.columnDefs.map((columnDef) => (
        <AgGridColumn {...columnDef} />
    ))}
</AgGridReact>

Default column definition is,默认列定义是,

defaultColDef: {
    sortable: true,
    filter: true,
    wrapText: true,
    autoHeight: true,
    menuTabs: ['filterMenuTab']
}

And my custom React component is,我的自定义 React 组件是,

import React from 'react';

const CustomRenderer = (props) => {
  return (
    <div
      style={{ height: '100%', whiteSpace: 'normal', wordBreak: 'break-all' }}>
      {props.value}
    </div>
  );
};

export default CustomRenderer;

For me it started working when also added fixed width, after adding below three properties to columnDef it started working for me对我来说,它在添加固定宽度时开始工作,在将以下三个属性添加到 columnDef 之后它开始为我工作

wrapText: true,
autoHieght: true,
width: 120

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM