Skip to content

Commit

Permalink
Merge pull request #120 from mercedes-benz/VULCAN-650/ExpandedCellRen…
Browse files Browse the repository at this point in the history
…derer

Vulcan 650/expanded cell renderer
  • Loading branch information
brahmprakashMishra authored May 17, 2024
2 parents 16a3d23 + 2da3e14 commit 50b93be
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/component/misc/DataGridExpandRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Box from '@mui/material/Box';
import { Paper, Popper, Typography } from '@mui/material';
import { GridRenderCellParams } from '@mui/x-data-grid';
import { useEffect } from 'react';
import {RenderString } from '../../report/ReportRecordProcessing';


interface GridCellExpandProps {
value: string;
Expand Down Expand Up @@ -105,15 +107,15 @@ const GridCellExpand = React.memo((props: GridCellExpandProps) => {
});

export function renderCellExpand(params: GridRenderCellParams<any, string>, lineBreakAfterListEntry: boolean) {

let value = params.value?.low ? params.value.low : params.value;

return (typeof value==="string" || value instanceof String)
? <GridCellExpand value={RenderString(value)} width={params.colDef.computedWidth} />
: <GridCellExpand value={JSON.stringify(value)
.replaceAll(',', lineBreakAfterListEntry ? ',\r\n' : ', ')
.replaceAll(']', '')
.replaceAll('[', '')
.replaceAll('"', '')} width={params.colDef.computedWidth} />;

const stringifiedObj = value
? JSON.stringify(value)
.replaceAll(',', lineBreakAfterListEntry ? ',\r\n' : ', ') // TODO: Consolidate to a regex
.replaceAll(']', '')
.replaceAll('[', '')
.replaceAll('"', '')
: '';

return <GridCellExpand value={stringifiedObj || ''} width={params.colDef.computedWidth} />;
}

0 comments on commit 50b93be

Please sign in to comment.