From ab3a493abbd11ab95e7d5a43d410f27be9ad1a83 Mon Sep 17 00:00:00 2001 From: leeheejin Date: Fri, 16 Jan 2026 14:03:07 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=BC=EB=B2=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pivot-grid/PivotGridComponent.tsx | 92 +++++++++---------- .../pivot-grid/PivotGridRenderer.tsx | 4 +- 2 files changed, 46 insertions(+), 50 deletions(-) diff --git a/frontend/lib/registry/components/pivot-grid/PivotGridComponent.tsx b/frontend/lib/registry/components/pivot-grid/PivotGridComponent.tsx index b55907a4..bdc00019 100644 --- a/frontend/lib/registry/components/pivot-grid/PivotGridComponent.tsx +++ b/frontend/lib/registry/components/pivot-grid/PivotGridComponent.tsx @@ -184,7 +184,7 @@ const DataCell: React.FC = ({ onClick={onClick} onDoubleClick={onDoubleClick} > - - + 0 ); } @@ -222,7 +222,7 @@ const DataCell: React.FC = ({ )} {icon && {icon}} - {values[0].formattedValue} + {values[0].formattedValue || (values[0].value === 0 ? '0' : values[0].formattedValue)} ); @@ -257,7 +257,7 @@ const DataCell: React.FC = ({ )} {icon && {icon}} - {val.formattedValue} + {val.formattedValue || (val.value === 0 ? '0' : val.formattedValue)} ))} @@ -530,14 +530,22 @@ export const PivotGridComponent: React.FC = ({ // πŸ†• 초기 λ‘œλ“œ μ‹œ 첫 레벨 μžλ™ ν™•μž₯ useEffect(() => { - if (!isInitialExpanded && pivotResult && pivotResult.flatRows.length > 0) { + if (pivotResult && pivotResult.flatRows.length > 0) { + console.log("πŸ”Ά ν”Όλ²— κ²°κ³Ό 생성됨:", { + flatRowsCount: pivotResult.flatRows.length, + expandedRowPaths: pivotState.expandedRowPaths.length, + isInitialExpanded, + }); + // 첫 레벨 ν–‰λ“€μ˜ 경둜 μˆ˜μ§‘ (level 0인 ν–‰λ“€) - const firstLevelPaths = pivotResult.flatRows - .filter(row => row.level === 0 && row.hasChildren) - .map(row => row.path); + const firstLevelRows = pivotResult.flatRows.filter(row => row.level === 0 && row.hasChildren); - if (firstLevelPaths.length > 0) { - console.log("πŸ”Ά 초기 μžλ™ ν™•μž₯:", firstLevelPaths); + console.log("πŸ”Ά 첫 레벨 ν–‰ (level 0, hasChildren):", firstLevelRows.map(r => ({ path: r.path, caption: r.caption }))); + + // 초기 ν™•μž₯이 μ•ˆ λ˜μ–΄ 있고, 첫 레벨 행이 있으면 μžλ™ ν™•μž₯ + if (!isInitialExpanded && firstLevelRows.length > 0) { + const firstLevelPaths = firstLevelRows.map(row => row.path); + console.log("πŸ”Ά 초기 μžλ™ ν™•μž₯ μ‹€ν–‰:", firstLevelPaths); setPivotState(prev => ({ ...prev, expandedRowPaths: firstLevelPaths, @@ -545,7 +553,7 @@ export const PivotGridComponent: React.FC = ({ setIsInitialExpanded(true); } } - }, [pivotResult, isInitialExpanded]); + }, [pivotResult, isInitialExpanded, pivotState.expandedRowPaths.length]); // 쑰건뢀 μ„œμ‹μš© 전체 κ°’ μˆ˜μ§‘ const allCellValues = useMemo(() => { @@ -1607,13 +1615,13 @@ export const PivotGridComponent: React.FC = ({ {/* μ—΄ 헀더 */} - + {/* μ’Œμƒλ‹¨ μ½”λ„ˆ (ν–‰ ν•„λ“œ 라벨 + ν•„ν„°) */} ))} + + {/* ν–‰ 총계 헀더 */} + {totals?.showRowGrandTotals && ( + + )} - {/* μ—΄ ν•„λ“œ ν•„ν„° (헀더 μ™Όμͺ½μ— ν‘œμ‹œ) */} + {/* μ—΄ ν•„λ“œ ν•„ν„° (헀더 였λ₯Έμͺ½ 끝에 ν‘œμ‹œ) */} {columnFields.length > 0 && ( )} - - {/* ν–‰ 총계 헀더 */} - {totals?.showRowGrandTotals && ( - - )} {/* 데이터 ν•„λ“œ 라벨 (닀쀑 데이터 ν•„λ“œμΈ 경우) */} {dataFields.length > 1 && ( - + {flatColumns.map((col, colIdx) => ( {dataFields.map((df, dfIdx) => ( @@ -1747,7 +1756,7 @@ export const PivotGridComponent: React.FC = ({ key={`${colIdx}-${dfIdx}`} className={cn( "border-r border-b border-border", - "px-2 py-1 text-center text-xs font-normal", + "px-2 py-0.5 text-center text-xs font-normal", "text-muted-foreground cursor-pointer hover:bg-accent/50" )} onClick={() => handleSort(df.field)} @@ -1760,19 +1769,6 @@ export const PivotGridComponent: React.FC = ({ ))} ))} - {totals?.showRowGrandTotals && - dataFields.map((df, dfIdx) => ( - - ))} )} diff --git a/frontend/lib/registry/components/pivot-grid/PivotGridRenderer.tsx b/frontend/lib/registry/components/pivot-grid/PivotGridRenderer.tsx index 08b21369..191f3610 100644 --- a/frontend/lib/registry/components/pivot-grid/PivotGridRenderer.tsx +++ b/frontend/lib/registry/components/pivot-grid/PivotGridRenderer.tsx @@ -210,7 +210,7 @@ const PivotGridWrapper: React.FC = (props) => { fieldChooser={componentConfig.fieldChooser || props.fieldChooser} chart={componentConfig.chart || props.chart} allowExpandAll={componentConfig.allowExpandAll !== false} - height={componentConfig.height || props.height || "400px"} + height="100%" maxHeight={componentConfig.maxHeight || props.maxHeight} exportConfig={componentConfig.exportConfig || props.exportConfig || { excel: true }} onCellClick={props.onCellClick} @@ -339,7 +339,7 @@ export class PivotGridRenderer extends AutoRegisteringComponentRenderer { fieldChooser={componentConfig.fieldChooser || props.fieldChooser} chart={componentConfig.chart || props.chart} allowExpandAll={componentConfig.allowExpandAll !== false} - height={componentConfig.height || props.height || "400px"} + height="100%" maxHeight={componentConfig.maxHeight || props.maxHeight} exportConfig={componentConfig.exportConfig || props.exportConfig || { excel: true }} onCellClick={props.onCellClick}
0 ? 2 : 1} > @@ -1657,8 +1665,8 @@ export const PivotGridComponent: React.FC = ({ key={idx} className={cn( "border-r border-b border-border relative group", - "px-2 py-1.5 text-center text-xs font-medium", - "bg-muted/70 sticky top-0 z-10", + "px-2 py-1 text-center text-xs font-medium", + "bg-background sticky top-0 z-10", dataFields.length === 1 && "cursor-pointer hover:bg-accent/50" )} colSpan={dataFields.length || 1} @@ -1680,16 +1688,31 @@ export const PivotGridComponent: React.FC = ({ /> 1 ? 2 : 1} + > + 총계 + 0 ? 2 : 1} + rowSpan={dataFields.length > 1 ? 2 : 1} >
{columnFields.map((f) => ( @@ -1721,25 +1744,11 @@ export const PivotGridComponent: React.FC = ({
- 총계 -
- {df.caption} -