AdaptTable for ngx-bootstrap

Row reordering in ngx-bootstrap

Compose rowReorder from @adapttable/ngx-bootstrap/row-reorder and a grip appears on every row. Drag it, or press Space to lift a row, the arrows to move it and Space to drop it; a live region announces each step.

The table never mutates your array: onRowReorder asks the host with the row's old and new positions and the row itself, and the host writes. This page applies each move with core's applyRowReorder and says what it did.

The code

import { Component, input, signal } from "@angular/core";
import { applyRowReorder } from "@adapttable/core";
import type { ColumnDef } from "@adapttable/angular";
import { AdaptDataTable } from "@adapttable/ngx-bootstrap";
import { rowReorder } from "@adapttable/ngx-bootstrap/row-reorder";

const columns: ColumnDef<Person>[] = [
  { key: "name", sortable: true },
  { key: "team" },
  { key: "budget", sortable: true },
];

@Component({
  selector: "app-people",
  imports: [AdaptDataTable],
  template: `
    <adapt-data-table
      [data]="order() ?? rows()"
      [columns]="columns"
      [rowKey]="rowKey"
      [features]="features"
    />
  `,
})
export class People {
  readonly rows = input.required<readonly Person[]>();
  readonly columns = columns;
  readonly rowKey = (row: Person) => row.id;
  readonly order = signal<readonly Person[] | null>(null);
  readonly features = [
    rowReorder<Person>((from, to) =>
      this.order.set(applyRowReorder(this.order() ?? this.rows(), from, to))
    ),
  ];
}

Install

# Follow the kit setup guide for compatible peers
pnpm add @adapttable/ngx-bootstrap @adapttable/angular ngx-bootstrap@22.0.0 @angular/forms@^22 rxjs@^7.4.0

The same feature in the other kits

More ngx-bootstrap features

Reference: row-reordering. More of this kit: AdaptTable for ngx-bootstrap, or the live demo.