How the display indices of the body rows move when rows are removed and inserted in one step (live data: tableApi.appendRows() / rowsAppended(), since 1.1.108) – so selection, focus and anchor stay at the same rows instead of being cleared. DOM-free.

Order: first the removed rows leave (indices before the step), then the inserted rows come in (indices after the step). An old row keeps its relative order.

Example

// 2 rows dropped at the start (ring buffer), 3 appended at the end of 10 → 11 rows
const shift = new RowIndexShift([0, 1], [8, 9, 10]);
shift.mapIndex(5); // 3
shift.mapIndex(1); // -1 (removed)

Example

// sorted: one row inserted at display index 2 (between the old rows 1 and 2)
const shift = new RowIndexShift([], [2]);
shift.mapRange(0, 4); // [[0, 1], [3, 5]] – the new row splits the range (it is not selected)

Since

1.1.108

Hierarchy

  • RowIndexShift

Constructors

Methods

  • The new display index of an old one.

    Parameters

    • index: number

      display index before the step

    Returns number

    the index after the step, -1 if the row was removed (or index is negative)

  • The display index after the step of the first remaining row at or after an old index – for a position that must stay on a row (e.g. the first visible row) when that row itself was removed.

    Parameters

    • index: number

      display index before the step

    Returns number

    the index after the step (the end if no old row at or after index remains)

  • The new ranges of an old range of rows lo … hi (inclusive): removed rows leave it, inserted rows inside split it (they are not part of it). hi = Number.MAX_SAFE_INTEGER (whole columns) stays open at the end.

    Parameters

    • lo: number

      first row of the range before the step

    • hi: number

      last row of the range before the step (inclusive)

    Returns [number, number][]

    the pieces after the step, ascending, [] if all its rows were removed

  • True if a row at an old display index <= index is removed or a row is inserted in front of the old row index (i.e. the rows 0 … index are not the same as before).

    Parameters

    • index: number

      an old display index

    Returns boolean

    true if the rows up to this index changed