Home / Docs / gn-vtable

Supported host API

This page summarizes the stable consumer surface of @gerald-neumann/gn-vtable 1.4.x. Import these APIs from the package root:

import {
  GnVTableComponent,
  VTableColumnDirective,
  type VTableDataProvider,
} from '@gerald-neumann/gn-vtable';

Components and directives

Key table bindings

Controlled state (models — source of truth)

State Bind
Search [(searchTerm)]
Sort [(sortColumns)]
Column filters [(columnFilters)]
Pivot [(pivotConfig)]
Group levels [(groupByLevels)]
Column order [(columnOrder)]
Column widths [(columnWidths)]
Selection ids [(selectedRowIds)] (null = uncontrolled)

Model change outputs use the Angular nameChange convention and emit the model value (not a wrapped { name: value } object). Prefer two-way bindings.

(selectionChange) remains for the rich { selectedRows, selectedRowIds } payload. Group delta outputs groupCriteriaAdd / Remove / Reorder remain for analytics.

Other supported inputs

Store-construction-only inputs (chunkSize, preFetchChunks, maxCachedChunks, initialLoadStrategy, performanceLogger, maxConcurrentChunkFetches) are read once when the internal store is created; changing them later is ignored (dev builds warn).

Other outputs

rowClick, actionClick, cellEditCommit, cellEditCancel, outlineToggle, dragStart, dragEnd, drop.

Supported imperative methods (frozen)

Method Purpose
reload(options?) Refresh data (optional countFirst / reload mode)
remeasureScrollport() Re-read scrollport geometry after host layout changes
setScrollTop(px) Programmatic vertical scroll
setSearchTerm(term) / clearSearch() Imperative search without two-way model
expandAllGroups() / collapseAllGroups() Group expand/collapse
expandGroupToLevel(level) / collapseGroupChildren(...) Partial group expand
getSelectedRows() / getSelectedRowIds() Selection query
clearColumnFilter(field) / clearAllColumnFilters() Filter clear
resetColumnWidths() Drop user/persisted width overrides
startEdit / applyEdit / commitEdit / endEdit / cancelEdit Inline edit

Companion panes may use visibleRows, companionLayout, companionVisibleRange, companionScrollTop, companionHeaderBandHeight, effectiveRowHeight, plus status signals loading, error, filteredRecords, totalRecords, and loadedRecords.

protected members are template-only and are not a supported host API.

Provider contract

Every VTableDataProvider<T> implements:

Grouped loading additionally uses both optional hooks:

fetchChildren is deprecated and is not called by the table. Handle (outlineToggle) in the host instead.

CI includes provider-conformance.spec.ts for minimal flat / group-first shapes.

Absolute minimum (hardcoded rows)

Runnable: .\start-minimum-sample.ps1 → http://localhost:4210 (projects/minimum-sample).

import { Component } from '@angular/core';
import { of } from 'rxjs';
import {
  GnVTableComponent,
  VTableColumnDirective,
  type VTableDataProvider,
} from '@gerald-neumann/gn-vtable';

type Person = { name: string; city: string };

const rows: Person[] = [
  { name: 'Ada Lovelace', city: 'London' },
  { name: 'Alan Turing', city: 'Manchester' },
  { name: 'Grace Hopper', city: 'New York' },
];

function filterRows(search?: string): Person[] {
  const q = search?.trim().toLowerCase();
  if (!q) return rows;
  return rows.filter(
    (r) => r.name.toLowerCase().includes(q) || r.city.toLowerCase().includes(q),
  );
}

@Component({
  imports: [GnVTableComponent, VTableColumnDirective],
  template: `
    <gn-vtable [dataProvider]="provider" [chunkSize]="50">
      <vtable-column field="name" title="Name" />
      <vtable-column field="city" title="City" />
    </gn-vtable>
  `,
})
export class MinimalTablePage {
  readonly provider: VTableDataProvider<Person> = {
    fetchDataCount: ({ search }) => of(filterRows(search).length),
    fetchData: ({ start, length, search }) => {
      const filtered = filterRows(search);
      return of({
        data: filtered.slice(start, start + length),
        recordsTotal: rows.length,
        recordsFiltered: filtered.length,
      });
    },
  };
}

Search is applied client-side above. Sort / column filters are still ignored — map sortColumns / columnFilters the same way (or swap the array for an HTTP provider).

Export tiers

Import Promise
@gerald-neumann/gn-vtable Supported host API (this page)
@gerald-neumann/gn-vtable/advanced Implementation helpers; may change between minors

Migration cheat sheet: MIGRATION-ADVANCED-EXPORTS.md.