Skip to main content
Locked columns remain visible at fixed positions while other columns scroll horizontally. This is useful for keeping key identifier columns (like names or IDs) always visible, or for pinning action columns to the right edge.

Overview

TeeGrid supports three locking modes for columns:
  • None — Column scrolls normally with other columns
  • Left — Column is locked to the left edge of the grid
  • Right — Column is locked to the right edge of the grid
When you lock columns, they’re excluded from horizontal scrolling and remain fixed in their positions.

Basic Usage

Locking a Column

Locking by Index

Column Lock Types

Visual Differentiation

Visually distinguish locked columns from scrollable ones:

Complete Example

Here’s a complete example from the TeeGrid demos showing locked columns:

Interactive Locking

Allow users to lock/unlock columns at runtime:

Context Menu for Column Locking

Locked Column Borders

Add visual separators between locked and scrollable columns:

Checking for Locked Columns

Saving and Restoring Lock State

Locked Columns with Selection

Locked columns work seamlessly with cell selection and range selection:

Performance Considerations

TeeGrid optimizes painting of locked columns. Locked columns are only repainted when necessary, not during horizontal scrolling.
While there’s no hard limit on locked columns, keeping the count reasonable (2-4 on each side) provides the best user experience and performance.
Locked columns reduce the available space for scrollable columns. Ensure your locked columns don’t consume too much horizontal space.

Best Practices

Lock key identifier columns — Lock columns containing IDs, names, or other key identifiers to the left so users can always see what row they’re looking at.
Lock action columns to the right — Columns with buttons, checkboxes, or action icons work well locked to the right edge.
Provide visual distinction — Use different background colors or borders to help users distinguish locked columns from scrollable ones.
Save user preferences — If users can lock/unlock columns, save their preferences and restore them on application startup.

Common Use Cases

Lock account name/number columns to the left, and total/balance columns to the right.
Lock product ID and name to the left, with action buttons (edit/delete) locked to the right.
Lock name column to the left so it remains visible while scrolling through many contact detail columns.
Lock timestamp column to the left for time reference while viewing log details.

Columns

Learn about column configuration and properties

Selection

Work with cell and range selection

Styling

Customize column appearance

TColumn API

Complete API reference for columns