This commit is contained in:
zwgczx committed 2026-03-11 17:41:08 +08:00
1 parent 3d26b0b259
commit 0f71fff9ac
11 files changed
+873 -205

No files matched your search

+18 -2
View File
@@ -32,8 +32,24 @@ export const gridOptions: GridOptions = {
groupDefaultExpanded: -1,
suppressFieldDotNotation: true,
// rowData 更新后通过稳定 ID 维持展开状态和编辑上下文。
getRowId: params => String(params.data?.id ?? params.data?.path?.join('/') ?? ''),
getDataPath: data => data.path,
getRowId: params => {
const id = params.data?.id
if (id != null && String(id).trim()) return String(id)
const path = Array.isArray(params.data?.path)
? params.data.path.map((segment: unknown) => String(segment ?? '').trim()).filter(Boolean)
: []
if (path.length > 0) return path.join('/')
return '__row__'
},
// 兜底避免 AG Grid #185:treeData 模式下 path 不能为空数组。
getDataPath: data => {
const path = Array.isArray(data?.path)
? data.path.map((segment: unknown) => String(segment ?? '').trim()).filter(Boolean)
: []
if (path.length > 0) return path
const fallback = String(data?.id ?? '').trim()
return [fallback || '__row__']
},
getContextMenuItems: () => ['copy', 'paste', 'separator', 'export'],
defaultColDef: {
resizable: true,