sticky column
This commit is contained in:
parent
8476b1de37
commit
8eded98a0b
@ -110,6 +110,8 @@ const HeaderCell = ({ header, table, pinningPosition, onClick, onChangeWidth })
|
|||||||
const isPinned = Boolean(pinningPosition);
|
const isPinned = Boolean(pinningPosition);
|
||||||
const leftOffset = pinningPosition === 'left' ? header.getStart() : undefined;
|
const leftOffset = pinningPosition === 'left' ? header.getStart() : undefined;
|
||||||
const rightOffset = pinningPosition === 'right' ? table.getRightTotalSize() - header.getStart() - headerSize : undefined;
|
const rightOffset = pinningPosition === 'right' ? table.getRightTotalSize() - header.getStart() - headerSize : undefined;
|
||||||
|
const stickyTextLeft = isPinned ? undefined : table.getLeftTotalSize();
|
||||||
|
const stickyTextRight = isPinned ? undefined : table.getRightTotalSize();
|
||||||
|
|
||||||
const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor;
|
const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor;
|
||||||
|
|
||||||
@ -161,11 +163,16 @@ const HeaderCell = ({ header, table, pinningPosition, onClick, onChangeWidth })
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
position: 'relative',
|
position: isPinned ? 'relative' : 'sticky',
|
||||||
|
left: stickyTextLeft,
|
||||||
|
right: stickyTextRight,
|
||||||
|
zIndex: 1,
|
||||||
paddingRight: '0.5rem',
|
paddingRight: '0.5rem',
|
||||||
paddingLeft: '0.5rem',
|
paddingLeft: '0.5rem',
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
color: color,
|
color: color,
|
||||||
|
maxWidth: 'calc(100% - 1rem)',
|
||||||
|
boxSizing: 'border-box',
|
||||||
}}>
|
}}>
|
||||||
{header.isPlaceholder ? null : column.columnDef.header}
|
{header.isPlaceholder ? null : column.columnDef.header}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user