bc-grid
GitHub

Click a header to sort. Shift-click another header to add a secondary sort. Per-column comparator and ‘sortable: false’ opt-out are both first-class.

Order #
Customer
Sales rep
Status
Amount
Opened
Region
R-000001
Customer 00001
Avery Chen
active
$0.00
2024-01-01
North
R-000002
Customer 00002
Ben Singh
pending
$31.42
2024-08-14
North
R-000003
Customer 00003
Cara Diaz
closed
$62.83
2024-03-27
North
R-000004
Customer 00004
Drew Lin
active
$94.25
2024-10-13
North
R-000005
Customer 00005
Elena Park
pending
$125.66
2024-05-26
South
R-000006
Customer 00006
Felix Roy
closed
$157.08
2024-12-12
South
R-000007
Customer 00007
Gita Bose
active
$188.50
2024-07-25
South
R-000008
Customer 00008
Henry Kao
pending
$219.91
2024-02-11
South
R-000009
Customer 00009
Avery Chen
closed
$251.33
2024-09-24
East
R-000010
Customer 00010
Ben Singh
active
$282.74
2024-04-10
East
R-000011
Customer 00011
Cara Diaz
pending
$314.16
2024-11-23
East
R-000012
Customer 00012
Drew Lin
closed
$345.57
2024-06-09
East
R-000013
Customer 00013
Elena Park
active
$376.99
2024-01-22
West
R-000014
Customer 00014
Felix Roy
pending
$408.41
2024-08-08
West
R-000015
Customer 00015
Gita Bose
closed
$439.82
2024-03-21
West

Try this

The Region column is opt-out (sortable: false) — clicking its header does nothing.

  • Click "Customer" — sorts ascending. Click again — descending. Third click — clears.
  • Click "Status". Then Shift+click "Customer". Now you have a multi-sort.
  • Right-click any header for sort actions in the context menu.
  • Click "Region" — nothing happens; it's opted out.

How sorting works

  • Per column. sortable: true is the default. Set false to opt out.
  • Multi-sort. Hold Shift while clicking headers. The first column is the primary sort, subsequent columns break ties.
  • Custom comparator. Pass comparator: (a, b, rowA, rowB) => number on the column. Useful for natural-numeric strings, locale-aware ordering, or business rules like "active before pending before closed".
  • Controlled mode. Set sort + onSortChange to drive sort from outside (URL state, saved views, parent component). Omit them and the grid manages its own sort state.