Locking ColumnsPremium
Locked (frozen, sticky, or pinned) columns remain visible at all times while the user scrolls the Grid horizontally.
By default, the columns of the Grid are not locked. The locked columns require all columns to have a fixed width.
The following example demonstrates how to lock and unlock Grid columns by setting the locked property, including toggling a column's locked state dynamically at runtime.
Locked Columns With Column Menu
The columnMenu can be used to render buttons that will lock and unlock a specific column on click.
In the following example we:
- Render a custom component inside the column menu that will lock and unlock the column.
- Update the columns collection when a column is locked/unlocked.
- Sort them by the
lockedfield to show all locked columns on the left.
The following example demonstrates how to lock and unlock Grid columns through a custom column menu button that updates the columns collection dynamically.
Locked Column With Custom Cell
When using pinned columns with a custom data cell, the specific styles and classes must be added to the td elements. The classes and styles will be part of the cell props.
The following example demonstrates a locked column that uses a custom data cell, passing the required styles and classes to the td element to maintain correct pinning behavior.