Skip to content

Commit

Permalink
Merge pull request #128 from mercedes-benz/develop
Browse files Browse the repository at this point in the history
Feature Deployment: Expand Cell Renderer
  • Loading branch information
brahmprakashMishra authored Jun 24, 2024
2 parents 7d2e9ed + f6c44fa commit 01335f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 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,18 @@ 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;

if(!value){
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} />;
}
2 changes: 1 addition & 1 deletion src/report/ReportRecordProcessing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function RenderArray(value) {
return mapped;
}

function RenderString(value) {
export function RenderString(value) {
const str = value?.toString() || '';
if (str.startsWith('http') || str.startsWith('https')) {
return (
Expand Down

0 comments on commit 01335f4

Please sign in to comment.