Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/TreeDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function TreeDataGrid<R, SR, K extends Key>(
groupBy.push(column.key);
columns[index] = {
...column,
frozen: true,
frozen: column.frozen ?? true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the data is grouped on two columns and only the first column has frozen: false?

renderCell: () => null,
renderGroupCell: column.renderGroupCell ?? renderToggleGroup,
editable: false
Expand Down
22 changes: 21 additions & 1 deletion website/demos/RowGrouping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const optionsClassname = css`
text-transform: capitalize;
`;

const hrClassname = css`
margin: 0;
`;

interface Row {
id: number;
country: string;
Expand Down Expand Up @@ -169,6 +173,8 @@ export default function RowGrouping({ direction }: Props) {
setExpandedGroupIds(new Set());
}

const [areGroupColumnsFrozen, setAreGroupColumnsFrozen] = useState<boolean>(true);

return (
<div className={groupingClassname}>
<b>Group by columns:</b>
Expand All @@ -185,8 +191,22 @@ export default function RowGrouping({ direction }: Props) {
))}
</div>

<hr className={hrClassname} />

<label>
<input
type="checkbox"
checked={areGroupColumnsFrozen}
onChange={() => setAreGroupColumnsFrozen(!areGroupColumnsFrozen)}
/>{' '}
Frozen group columns
</label>

<TreeDataGrid
columns={columns}
columns={columns.map((c) => ({
...c,
...(selectedOptions.includes(c.key) ? { frozen: areGroupColumnsFrozen } : {})
}))}
rows={rows}
rowKeyGetter={rowKeyGetter}
selectedRows={selectedRows}
Expand Down