@jsvision/datagrid / reorderWithinPanel
Function: reorderWithinPanel()
reorderWithinPanel(
visible,freeze,from,to):string[]
Defined in: datagrid/src/column-model.ts:117
Move a column within its own panel (a reorder). from/to are indices into the effective visible order ([...left, ...center, ...right]). A move that would cross a panel (freeze) boundary is rejected — the order is returned unchanged — so a frozen column can never be dragged out of its panel and a scrolling column can never be dragged into a frozen one (the within-panel reorder rule).
Parameters
visible
readonly string[]
The visible column ids, in effective (grouped) order.
freeze
The freeze spec (defines the panel boundaries).
from
number
The source index.
to
number
The destination index.
Returns
string[]
The reordered ids, or a copy of the input unchanged when the move is out of range, a no-op, or crosses a freeze boundary.
Example
import { reorderWithinPanel } from '@jsvision/datagrid';
// freeze:1 → left=[id], center=[name,dept,note]; move 'dept' (2) before 'name' (1):
reorderWithinPanel(['id', 'name', 'dept', 'note'], { freeze: 1 }, 2, 1);
// ['id', 'dept', 'name', 'note']
// a center→left move is rejected:
reorderWithinPanel(['id', 'name', 'dept'], { freeze: 1 }, 1, 0); // ['id', 'name', 'dept']