Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/VirtualTable/BodyGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useFlattenRecords, { type FlattenData } from '../hooks/useFlattenRecords'
import type { ColumnType, OnCustomizeScroll, ScrollConfig } from '../interface';
import BodyLine from './BodyLine';
import { GridContext, StaticContext } from './context';
import { getColumnsKey } from '../utils/valueUtil';

export interface GridProps<RecordType = any> {
data: RecordType[];
Expand Down Expand Up @@ -58,7 +59,9 @@ const Grid = React.forwardRef<GridRef, GridProps>((props, ref) => {
// ========================== Column ==========================
const columnsWidth = React.useMemo<[key: React.Key, width: number, total: number][]>(() => {
let total = 0;
return flattenColumns.map(({ width, minWidth, key }) => {
const columnKeys = getColumnsKey(flattenColumns);
return flattenColumns.map(({ width, minWidth }, index) => {
const key = columnKeys[index];
const finalWidth = Math.max((width as number) || 0, (minWidth as number) || 0);
total += finalWidth;
return [key, finalWidth, total];
Expand Down
2 changes: 1 addition & 1 deletion src/utils/valueUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getColumnsKey<T = any>(columns: readonly GetColumnKeyColumn<T>[]
columns.forEach(column => {
const { key, dataIndex } = column || {};

let mergedKey = key || toArray(dataIndex).join('-') || INTERNAL_KEY_PREFIX;
let mergedKey = key ?? toArray(dataIndex).join('-') ?? INTERNAL_KEY_PREFIX;
while (keys[mergedKey as string]) {
mergedKey = `${mergedKey}_next`;
}
Expand Down