From 00f58ebe16e52e87afd07d431ed1e4aff12af240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Tue, 21 Jul 2026 16:57:12 +0800 Subject: [PATCH] feat(grid): show details for read-only cells --- apps/desktop/src/components/grid/DataGrid.vue | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 72920aaa5..7a676223b 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -2855,6 +2855,17 @@ function startDomCellEdit(rowId: number, columnIndex: number, displayText: strin startCellEdit(rowId, columnIndex, cellEditContentNeedsExpandedEditor({ displayText, editText, target: event.currentTarget })); } +function showReadonlyCellDetailsOnDblClick(item: RowItem, rowIndex: number, visibleColIdx: number, actualColIdx: number): boolean { + if (canEditCellItem(item, actualColIdx)) return false; + showCellDetailsForVisibleCell(rowIndex, visibleColIdx, actualColIdx); + return true; +} + +function onDomCellDblClick(item: RowItem, rowIndex: number, visibleColIdx: number, actualColIdx: number, event: MouseEvent) { + if (showReadonlyCellDetailsOnDblClick(item, rowIndex, visibleColIdx, actualColIdx)) return; + startDomCellEdit(item.id, actualColIdx, formatCellCached(item.data[actualColIdx], actualColIdx), event); +} + function cellEditContentNeedsExpandedEditor(options: { displayText: string; editText: string; target: EventTarget | null }): boolean { const text = options.editText || options.displayText; if (text.includes("\n") || text.includes("\r")) return true; @@ -4687,7 +4698,8 @@ function onCanvasDblClick(event: MouseEvent) { } const item = displayItemAt(hit.rowIndex); const actualColIdx = visibleColumnIndexes.value[hit.visibleColIdx]; - if (!item || actualColIdx === undefined || !canEditCellItem(item, actualColIdx)) return; + if (!item || actualColIdx === undefined) return; + if (showReadonlyCellDetailsOnDblClick(item, item.displayIndex, hit.visibleColIdx, actualColIdx)) return; startCellEdit(item.id, actualColIdx, canvasCellContentOverflows(item, actualColIdx, hit.visibleColIdx)); } @@ -5258,6 +5270,16 @@ function showTransposeCellDetails(rowIndex: number, actualColIdx: number) { gridRef.value?.focus({ preventScroll: true }); } +function onTransposeCellDblClick(rowIndex: number, actualColIdx: number, displayText: string, event: MouseEvent) { + const item = displayItemAt(rowIndex); + if (!item) return; + if (!canEditCellItem(item, actualColIdx)) { + showTransposeCellDetails(rowIndex, actualColIdx); + return; + } + startDomCellEdit(item.id, actualColIdx, displayText, event); +} + function onTransposeCellContext(rowIndex: number, actualColIdx: number, event: MouseEvent) { selectTransposeCell(rowIndex, actualColIdx, event); const item = displayItemAt(rowIndex); @@ -7716,7 +7738,7 @@ const gridContextMenuItems = computed(() => { @mouseenter="onTransposeCellMouseenter(cell.recordIndex, cell.valueIndex)" @mouseleave="onCellMouseleave(cell.recordIndex, cell.valueIndex)" @contextmenu="onTransposeCellContext(cell.recordIndex, cell.valueIndex, $event)" - @dblclick.stop="canEditCellItem(displayItems[cell.recordIndex], cell.valueIndex) && startDomCellEdit(displayItems[cell.recordIndex].id, cell.valueIndex, cell.display, $event)" + @dblclick.stop="onTransposeCellDblClick(cell.recordIndex, cell.valueIndex, cell.display, $event)" >