JGJS2026/src/lib/diyAgGridOptions.ts
2026-03-07 11:47:07 +08:00

50 lines
1.3 KiB
TypeScript

import type { GridOptions } from 'ag-grid-community'
import { themeQuartz } from 'ag-grid-community'
const borderConfig = {
style: 'solid',
width: 0.3,
color: '#d3d3d3'
}
export const myTheme = themeQuartz.withParams({
wrapperBorder: false,
wrapperBorderRadius: 0,
headerBackgroundColor: '#f0f2f3',
headerTextColor: '#374151',
headerFontSize: 15,
headerFontWeight: 'normal',
rowBorder: borderConfig,
columnBorder: borderConfig,
headerRowBorder: borderConfig,
dataBackgroundColor: '#fefefe'
})
export const gridOptions: GridOptions = {
treeData: true,
animateRows: true,
tooltipShowMode: 'whenTruncated',
suppressAggFuncInHeader: true,
singleClickEdit: true,
stopEditingWhenCellsLoseFocus: true,
suppressClickEdit: false,
suppressContextMenu: false,
groupDefaultExpanded: -1,
suppressFieldDotNotation: true,
// rowData 更新后通过稳定 ID 维持展开状态和编辑上下文。
getRowId: params => String(params.data?.id ?? params.data?.path?.join('/') ?? ''),
getDataPath: data => data.path,
getContextMenuItems: () => ['copy', 'paste', 'separator', 'export'],
defaultColDef: {
resizable: true,
sortable: false,
filter: false,
wrapHeaderText: true,
autoHeaderHeight: true
},
defaultColGroupDef: {
wrapHeaderText: true,
autoHeaderHeight: true
}
}