Column sizing and pinning
Drag column boundaries to resize and pin important columns on either side.
Options
Changes below update the Grid and code immediately.
Order IDs start pinned on the left. When the table is wider than the screen, horizontal scrolling moves other columns while order IDs remain visible.
View code
Sample data included in the code · 6 rows
Usage guide
#Useful for inspecting amounts on the right while keeping order IDs visible in a wide table. Widen columns to read long product names.
Try it yourself
- Inspect default pinning
Order IDs start pinned on the left. When the table is wider than the screen, horizontal scrolling moves other columns while order IDs remain visible.
- Change the pinning position
Below the table, change Product column pinning to Pin left or Pin right. Choose Unpinned to return it to the regular area.
- Adjust column width
Enter 280 for Product column width or drag the product header's right boundary. Double-click the boundary to size it to the content.
The column is pinned on the selected side and its width changes immediately. Check the input values and code below too.
Pinning several columns on narrow screens leaves less space for the rest. Pin only essential identifying columns first.
Useful terms
- pinned
- Pins a column to the left or right.
- width
- Column width, measured in pixels.
Key API examples
Application code that references the registered Grid element as grid.
await grid.setColumnPinned('id', 'left');
await grid.setColumnWidth('product', 220);API reference
#Key properties
| Attribute / Property | Type / Default | Description |
|---|---|---|
| resizableColumns | booleanDefault: false | Enable draggable column resize handles. |
| reorderableColumns | booleanDefault: false | Enable header drag column reordering. |
| columnHiding | booleanDefault: false | Enable the runtime column visibility method surface. |
Other properties2
| Attribute / Property | Type / Default | Description |
|---|---|---|
| hideableColumns | booleanDefault: false | Select a name to inspect its type contract. |
| autoSizeOnDoubleClick | booleanDefault: true | Enable header double-click auto-size when column resizing is enabled. |
Events3
| Events | Detail type | Description |
|---|---|---|
GridColumnResizedDetail | Fires after a committed column resize. | |
GridColumnReorderedDetail | Fires after a committed column reorder. | |
GridColumnVisibilityChangedDetail | Fires after an effective column visibility change. |
Methods17
| Method / Arguments | Return type | Description |
|---|---|---|
| colId: string, width: number | Promise<void> | Set a column width, respecting min/max bounds. |
| colId: string | Promise<void> | Clear a live column-width override. |
| colId: string | Promise<number | null> | Read the effective width for a column id. |
| field: string, side: ColumnPinSide | null | Promise<void> | pin/unpin a column at runtime (`null` = unpin). Unknown fields are rejected with a warning. `'right'` becomes fully functional on ; the model accepts it already so column state snapshots round-trip. |
| field: string | Promise<ColumnPinSide | null> | effective pin side of a column (override-aware). |
| orderedColIds: string[] | Promise<void> | Set the effective column order. |
Promise<string[]> | Read the effective column order. | |
| colId: string | Promise<void> | Hide a single column. |
| colId: string | Promise<void> | Show a single column. |
| colId: string | Promise<boolean> | Toggle a column's hidden state and return the new state. |
| colIds: string[] | Promise<void> | Replace hidden-column state from a field list. |
Promise<void> | Clear all hidden-column state. | |
Promise<string[]> | Read the current hidden-column ids. | |
| colId: string | Promise<number | null> | Auto-size a single column from visible content. |
Promise<void> | Auto-size every visible, resizable column. | |
Promise<ColumnStateEntry[]> | Snapshot column width, order, visibility, (multi-)sort and pin state. | |
| state: ColumnStateEntry[], opts?: ApplyColumnStateOptions | Promise<void> | Restore column state from a snapshot. |
ColumnDef9
| ColumnDef | Type / Required | Description |
|---|---|---|
numberOptional | Fixed column width in pixels. | |
numberOptional | Lower bound for column width in pixels. | |
numberOptional | Upper bound for column width in pixels. | |
numberOptional | Flex factor — distributes leftover horizontal space (CSS-flex semantics). | |
booleanOptional | Per-column override for wrapper-level column resizing. | |
booleanOptional | Per-column override for wrapper-level column reordering. | |
'left' | 'right' | nullOptional | pin this column to an edge: pinned columns render before (left) / after (right) the scrolling middle block and stick while it scrolls horizontally. Pinned columns need a concrete pixel width (`width` or a live resize); flex-sized pinned columns fall back to a 150px default. Runtime `setColumnPinned` overrides this declaration. | |
booleanOptional | Initial hidden state; runtime visibility state owns later changes. | |
booleanOptional | AG Grid compatibility alias for ; `hidden` wins when both are set. |
Explore each feature
Learn when to use each feature and how to configure it. Each guide identifies live examples and features you connect in your app.