LyteNyte Grid logo for light mode. Links back to the documentation home page.
Columns

Column Moving

Columns in LyteNyte Grid may be reordered programmatically or through the grid's drag-and-drop header interactions. Column groups can also be reordered as a unit.

Move By Dragging

LyteNyte Grid supports column reordering through the uiHints property on each column definition. Set movable to true to allow users to drag a column header to a new position. Click and hold to drag a header in the demo below:

Move By Dragging

The demo enables moving for all columns by setting movable on the base column:

const grid = Grid.useLyteNyte({
// Other grid props
columnBase: {
uiHints: {
movable: true,
},
},
});

Pinned Columns & Drag Reordering

When the grid has both pinned and scrollable columns, drag-and-drop reordering updates the column's pin state depending on where you drop it.

  • Moving an unpinned column over a pinned column causes the moved column to become pinned.
  • Moving a pinned column over an unpinned one unpins the moved column.

Crossing the pinned or scrollable boundary when moving columns changes the pin state. However, reordering columns within the same section without crossing the boundary leaves it unchanged. The demo below shows this boundary-based behavior.

Moving Pinned Columns

Dragging Column Groups

Columns in the same group can be dragged together. All columns in the group must be movable for group dragging to work. In the demo below, dragging the Inventory group moves both the Product and Price columns:

Moving Column Groups

Moving grouped columns can change the group hierarchy:

  • If you drag a column out of its group, LyteNyte splits the group.
  • If two columns belong to the same group but are separated in the header hierarchy, dragging them next to each other merges the header hierarchy.
  • Reordering columns within the same group behaves the same as reordering ungrouped columns.
  • If you move an ungrouped column between columns in a group, LyteNyte splits the group.

See the Column Groups guide for details on when groups split and how LyteNyte Grid handles column groups.

Programmatic Column Reordering

Use api.columnMove to reorder columns programmatically. Column order is determined by the sequence of columns in the grid state, and api.columnMove updates grid.state.columns accordingly. For example, the code below swaps the ID and Product columns:

grid.api.columnMove({ moveColumns: ["product"], moveTarget: "id", before: false });

For more details, see the Grid API reference.

Next Steps

  • Column Base: See the default column values and how to override them.
  • Column Resizing: Change column widths programmatically or through user interaction.
  • Column Pinning: Pin columns to the start or end of the viewport.
  • Column Groups: Create a column header hierarchy and associate columns with column groups.