reactjs MUI Datatable -使用聚合时如何设置行样式

gudnpqoy  于 2023-04-29  发布在  React
关注(0)|答案(1)|浏览(132)

目前使用自定义样式的行/列,也将样式的聚合列。如何在不影响聚合行的情况下设置此行的样式?
https://codesandbox.io/s/frosty-euler-1szk2y?file=/demo.tsx

v1l68za4

v1l68za41#

您可以在renderCell中设置它:=

{
        field: SomeFieldName,
        headerName: SomeHeaderName,
        type: number,
        width: 140,
        renderCell: renderCellFunction,
}



export const renderCellFunction = (params: GridRenderCellParams<Partial<RowDataType>, any, any, GridTreeNodeWithRender>) => {
    if (params.aggregation) {
        return <Typography color="primary.main">{params.formattedValue}</Typography>;
    }
    return (
        <div>
            <Typography>{params.row.xyz}</Typography>
        </div>
    );
};

相关问题