The Table renders an array of row objects as a data grid with sorting,
per-column filtering, single and multi selection, row grouping, column
resize/reorder/sticky, pagination, virtual scrolling, and per-row actions.
Structure is opt-in and declarative — you enable each feature by adding a
directive to a header cell or an input to jig-table.
Data is client-side by default. Sorting, filtering, grouping and pagination all operate on the in-memory
rowsarray (the pipeline is filter → sort → group → paginate). For server-driven data, providedataSourceinstead (see "Lazy Loading" further down) — sort/filter are then delegated to the loader and grouping is unsupported. Thevirtualinput is about rendering (only visible rows hit the DOM) independent of lazy loading, though the two combine for infinite scroll.
You provide a #header template of <th jigTableTh> cells and a #body
template of <td jigTableTd> cells, then turn features on with directives such
as jigTableSortableColumn, jigTableFilterableColumn, or
jigTableStickyColumn. rows and fieldId are required — fieldId names the
property that uniquely identifies each row and is used for selection keys and row
tracking. Give the table a fixed height, as it scrolls its body internally.
One table with most features enabled at the same time: multi selection with checkboxes, sortable and filterable columns, a sticky ID column, column resize and reorder, pagination and per-row actions (hover a row, or right-click it). Each feature is explained on its own in the examples below.
Set selectionMode to 'single' or 'multi' (or leave it null to disable
selection) and two-way bind [(selection)], an array of row IDs (the fieldId
values). In multi mode use Ctrl-click to toggle individual rows and Shift-click
to extend a range; add a <th jigTableSelectionColumn> / <td jigTableSelectionColumn>
pair to get per-row checkboxes plus a header select-all checkbox (which shows an
indeterminate state on a partial selection).
Add jigTableSortableColumn to a header cell. Clicking the header cycles the
sort ascending → descending → unsorted, reflected in the two-way [(sort)]
model ({ column, direction } or null). The default comparator handles
numbers numerically and everything else via localeCompare, with nulls first
on ascending; pass a sortComparator to override it. Set sortClearable to
false to drop the unsorted step and toggle between ascending and descending
only. The active header carries aria-sort="ascending" | "descending".
Set [sortLocally]="false" to sort on the server: the headers still drive
[(sort)], but the table renders rows in the order you hand it.
Add jigTableFilterableColumn with a …Type (the column's data type, which
picks the available operators and UI) and, for list filters, a …Items option
set — plain strings, or { label, value } items when the shown text differs
from the stored value. A filter button appears in the header and opens a filter popover; applied
filters live in the two-way [(filters)] model, keyed by column. Multiple
column filters combine (AND). A …Operators list narrows and orders the
operators of that column, and …DefaultOperator picks the one a new condition
starts with. Edits apply as the user types; set …AutoApply to false for
apply / cancel buttons, and …AllowMultiple to false to keep a column to a
single condition.
…Template takes a TemplateRef and replaces that column's popover with your
own editor — a slider, a rating, a lookup against your backend. It writes an
ordinary JigFilterConfig back through the context's setValue, so the column
filters, combines and serializes exactly as a built-in one does. See the filter
field's page for the full context.
Set [filterLocally]="false" for server-side filtering without handing paging
over to dataSource: the header controls still drive [(filters)], but the
table renders rows as given, so you refetch them yourself when filters
changes. Pair it with [sortLocally]="false" when the server sorts too. Pass
…Items for list columns — options derived from rows would
only ever cover the rows currently loaded. Since you own the request, bind
loading to it for skeleton rows — the table only sees
rows arrive and cannot tell a fetch is in flight by itself.
Set groupBy to a column key to collect rows sharing that value under
collapsible group-header rows (each showing the group value and its count).
Two-way bind [(expandedGroups)] (an array of group values) to control which
groups are open — it defaults to [] (all collapsed), so pass every group value
to start expanded. Grouping is applied after sorting, so a group's rows honour
the active sort.
Set paginator to render a jig-paginator below the grid and page the rows
client-side. Combine freely with sorting and filtering — paging is the last step
of the pipeline, so it pages the already-sorted/filtered result.
Set virtual and provide a fixed rowHeight to render only the rows in (and a
small virtualPadding around) the viewport. This keeps very large datasets
smooth. Because rows are recycled, avoid stateful per-row DOM outside the
control's own machinery.
Set resizable to add drag handles to header cells; double-clicking a handle
auto-sizes the column to its content. Each jigTableTh accepts a size
(e.g. '1fr', '200px', '25%'), minSize, and maxSize. resizeMode
chooses how the drag distributes width: 'adjacent' (default) keeps the total
width constant by shrinking the neighbour, while 'push' lets the column grow
independently and enables horizontal scrolling. lockSizes controls whether
affected columns are pinned to fixed px after a resize.
Set reorderable to let users drag column headers into a new order (a drop
indicator shows the target position). The order is exposed through the two-way
[(columnOrder)] model — an array of column IDs — which you can persist and
restore. An empty array means natural DOM order.
Add jigTableStickyColumn="start" or ="end" to a header cell to pin that
column to the left or right edge while the rest of the grid scrolls
horizontally. Multiple sticky columns stack against their edge.
Add jigTableRowActions to a body <tr> with a jigActionItem[]. By default
the same actions are exposed two ways (both independently toggleable): a
right-click context menu (…Context) and an inline button-bar at the row's edge
revealed on hover or keyboard focus (…Inline). Actions may nest via children
to open submenus. A callback receives the triggering event, so
event.currentTarget can anchor a popover to the clicked button. The keyboard context menu (Enter / ContextMenu / Shift+F10 on
the current row) is always available even when the right-click affordance is off.
Set loading to replace the body with skeleton rows while you fetch data
yourself — the client-side counterpart to the state dataSource tracks on its
own. Override the placeholders with an <ng-template #loading>.
Provide a dataSource loader instead of rows to fetch rows on demand — the
table switches into lazy mode, delegating sort/filter to the loader and
ignoring rows. The loader receives a TableLoadRequest (page/slice
coordinates, active sort/filters, and an abort signal for superseded requests)
and resolves a TableLoadResult (rows, hasMore, and optionally
total/cursor). Incompatible with groupBy.
With paginator, the loader is called with pagination.slice.skip/.take for
the requested page:
Without paginator, set virtual and rowHeight to infinite-scroll: the
table calls the loader again as the user scrolls near the end, appending rows
until hasMore is false.
Omit total from the result and return a cursor instead to switch the
paginator into compact mode (next/previous only, no page count) — useful for
cursor-based backends where the total row count isn't known.
Pass a storage config (key + optional JigStorageKind) to save the table's
state across reloads via JigStorage. Everything the user can change is
persisted: sort, filters, columnOrder, columnSizes, selection,
expandedGroups and page (index + size). Use states to persist only some
of them, e.g. { key: 'my-table', states: ['sort', 'columnSizes'] }. The kind
accepts 'localstorage' (default), 'sessionstorage', or 'cookie' — the
cookie kind is SSR-safe and restores state during server rendering.
jig