Skip to main content

Core Web Component API Reference

The <pivot-head> web component exposes a rich API through HTML attributes (for initial setup) and JavaScript properties, methods, and events (for dynamic interaction).
This allows developers to easily integrate headless pivot table functionality into any web project.


Properties / Attributes

These can be set as HTML attributes (using kebab-case, e.g., data-url) or as JavaScript properties (using camelCase, e.g., pivot.dataUrl).

PropertyAttributeTypeDescription
datadataobject[]The raw dataset (as a JSON string in HTML).
optionsoptionsobjectThe pivot configuration (as a JSON string in HTML).
dataUrldata-urlstringURL to fetch the raw JSON data from.
optionsUrloptions-urlstringURL to fetch the JSON configuration from.
modemodestringRendering mode: default, minimal, or none.
filtersfiltersFilter[]Sets the active filters.
paginationpaginationPaginationSets the pagination configuration.

Methods

You can call these methods on the DOM element instance (for example, document.querySelector('pivot-head').refresh()).

MethodParametersReturnsDescription
getState()PivotTableStateGets the current component state.
refresh()voidRefreshes the pivot engine.
sort()field: string, direction: 'asc' | 'desc'voidSorts the data by a specified field.
addFilter()field: string, operator: string, value: anyvoidAdds a filter to the data.
clearFilters()voidRemoves all active filters.
setPageSize()size: numbervoidSets the number of items per page.
nextPage()voidNavigates to the next page.
previousPage()voidNavigates to the previous page.
exportToPDF()fileName?: stringvoidExports the current view as a PDF.
exportToExcel()fileName?: stringvoidExports the current view as an Excel file.
exportToHTML()fileName?: stringvoidExports the current view as an HTML file.
print()voidOpens the browser’s print dialog.
setViewMode()mode: 'processed' | 'raw'voidSwitches between raw and processed data views.
getRawData()object[]Gets the original, unfiltered dataset.
getProcessedData()objectGets the processed pivot data.

Events

You can listen for the following events on the DOM element (for example, pivot.addEventListener('stateChange', ...)).

EventDetail TypeDescription
stateChangePivotTableStateFired whenever the internal state changes.
filterChangeFilterStateFired when filters are added, removed, or modified.
sortChangeSortStateFired when sorting is applied.
pageChangePaginationStateFired when the page changes.