From 6f300918cdb363cadd49c7dad08246b80f3da9df Mon Sep 17 00:00:00 2001 From: rsone001 Date: Wed, 21 Oct 2026 16:04:41 +0900 Subject: [PATCH] =?UTF-8?q?[ST]=20-=20fix:=20=EA=B7=B8=EB=A6=AC=EB=93=9C?= =?UTF-8?q?=20=EC=97=AC=EB=9F=AC=ED=96=89=20=EB=B3=B5=EC=82=AC=20=EB=B6=99?= =?UTF-8?q?=EC=97=AC=EB=84=A3=EA=B8=B0=20=EC=8B=9C=20=EC=B4=88=EA=B3=BC?= =?UTF-8?q?=EB=90=9C=20=ED=96=89=20=EC=88=98=20=EB=A7=8E=ED=81=BC=20?= =?UTF-8?q?=EB=B9=88=ED=96=89=EC=9D=B4=20=EC=B6=94=EA=B0=80=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/st/src/components/module/DataGrid.tsx | 25 +++++++++++++++++--- apps/st/src/components/type/DataGrid.type.ts | 5 ++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/apps/st/src/components/module/DataGrid.tsx b/apps/st/src/components/module/DataGrid.tsx index a87005031..cef70a624 100644 --- a/apps/st/src/components/module/DataGrid.tsx +++ b/apps/st/src/components/module/DataGrid.tsx @@ -289,14 +289,28 @@ type GridViewWithSetColumnProperty = { }; type GridViewWithEditOptions = { - setEditOptions?: (options: { commitWhenLeave?: boolean }) => void; + setEditOptions?: (options: { + commitWhenLeave?: boolean; + appendable?: boolean; + insertable?: boolean; + }) => void; + setPasteOptions?: (options: { enableAppend?: boolean }) => void; }; /** 포커스가 그리드 밖으로 나갈 때 편집 중인 값을 자동 commit */ function applyDefaultGridEditOptions( gridView: GridViewWithEditOptions | null | undefined, + options?: { preventRowAppend?: boolean }, ) { - gridView?.setEditOptions?.({ commitWhenLeave: true }); + gridView?.setEditOptions?.({ + commitWhenLeave: true, + ...(options?.preventRowAppend + ? { appendable: false, insertable: false } + : {}), + }); + if (options?.preventRowAppend) { + gridView?.setPasteOptions?.({ enableAppend: false }); + } } function isDateEditorColumn(column: { @@ -853,6 +867,7 @@ const DataGrid = ({ gridHeight = 55, // vh 단위 headerHeight = 60, fitStyle = GridFitStyle.EVEN, + preventRowAppend = true, }: DataGridProps) => { const { columns, columnLayout } = columnInfo; const fixedColumnNameSet = useMemo( @@ -1467,7 +1482,9 @@ useEffect(() => { const scheduleFooterTask = (task: () => void, delayMs: number) => { footerTimerIds.push(setTimeout(task, delayMs)); }; - applyDefaultGridEditOptions(gridView as GridViewWithEditOptions); + applyDefaultGridEditOptions(gridView as GridViewWithEditOptions, { + preventRowAppend, + }); const columnsFieldsSig = columns.map((c) => c.fieldName).join("\u0001"); if (columnsFieldsSig !== columnsFieldsSigRef.current) { @@ -1990,6 +2007,7 @@ useEffect(() => { fitStyle, enableSort, footerVerificationResult, + preventRowAppend, ]); // 행·셀 클릭 이벤트 (검증 오류 툴팁은 hover만 — onShowTooltip / 빈 셀 오버레이) @@ -2527,6 +2545,7 @@ useEffect(() => { const gridView = gridRef.current?.gridView ?? grid; applyDefaultGridEditOptions( gridView as GridViewWithEditOptions, + { preventRowAppend }, ); if (!gridView?.columnByName) return; setTimeout(() => { diff --git a/apps/st/src/components/type/DataGrid.type.ts b/apps/st/src/components/type/DataGrid.type.ts index 7d2a82625..0899bf560 100644 --- a/apps/st/src/components/type/DataGrid.type.ts +++ b/apps/st/src/components/type/DataGrid.type.ts @@ -481,6 +481,11 @@ export type DataGridProps = { headerHeight?: number; /** RealGrid `displayOptions.fitStyle` (기본 EVEN). 컬럼별 width 유지 시 NONE */ fitStyle?: GridFitStyle; + /** + * true면 붙여넣기·편집으로 행을 추가하지 않음. + * 검증 결과처럼 조회 행 수가 고정된 그리드에서 사용. + */ + preventRowAppend?: boolean; }; export type TabDataGridProps = {