Documentation

@kanunilabs/pivotgrid-react


@kanunilabs/pivotgrid-react / PivotControllerOptions

Interface: PivotControllerOptions<TRow>

Options for initializing a PivotController.

Extends

Type Parameters

TRow

TRow = any

Properties

asyncTransactionWait?

optional asyncTransactionWait?: number

How long applyTransactionAsync collects transactions before applying them together. Default 50 ms.


chartIntegrationOptions?

optional chartIntegrationOptions?: Record<string, any>


columnar?

optional columnar?: boolean

Keep the rows as typed columns instead of row objects (Enterprise, B.111): about 350–450 bytes per source row instead of the size of your row objects, for 1–2 million rows in the browser. Rows are built only when something reads them. Read once, at construction; changing it later does nothing.

In this mode rows come as { columns, rows } chunks (PivotRowChunk) or as objects, through data, setData and applyTransaction(Async)({ add }); update and remove are not supported yet and throw. data follows the row-mode rule: a new value replaces the rows and a new empty one clears them; the same value again does not (a chunk counts as the same while its rows and columns arrays are). A row-level calculateExpression gets one read-only (frozen) row object for every row of a pass: read from it, do not keep it. getRawData() returns a read-only list whose rows are built when read; for large reads use rowStoreOf, cellRowSource and selectionRowSource from an Enterprise package. Requires EnterprisePivotGrid (or enterpriseEdition: true with an Enterprise package imported). Default false.


controlledFields?

optional controlledFields?: PivotField<TRow, PivotCellTemplate, any>[]


controlledLayout?

optional controlledLayout?: PivotLayoutState


data

data: TRow[]

The rows. With columnar, a { columns, rows } chunk (PivotRowChunk) is taken too: pass it with a cast here (chunk as never), or use the React / plain JS grid props and setData, which are typed for it.


dictionary?

optional dictionary?: Partial<PivotDictionary>

The grid's resolved dictionary (the locale's words and the app's overrides). The renderers set it; exports take the words of the file from it (B.68).

Inherited from

PivotControllerCallbacks.dictionary


enterpriseEdition?

optional enterpriseEdition?: boolean

Turns on the Enterprise edition for this controller.

BasePivotGrid sets it from the advancedExport prop, which is what EnterprisePivotGrid passes — so a normal React app never touches this. It exists because usePivotController, PivotGridBody and PivotFooter are all public: building your own shell is supported, and without a documented way in, that path would go from "exports a file" to "throws" with nothing to set.


gridId

gridId: string


initialFields

initialFields: PivotField<TRow, PivotCellTemplate, any>[]


loading?

optional loading?: boolean

The application is still fetching the rows (a customer): while true, noData stays false, so a grid mounted with data: [] shows its loader instead of the empty text until the rows arrive. A result already on screen stays on screen. exportData does not wait for it — only for isComputing. Change it with setLoading. Default false.


locale?

optional locale?: string


maxColumns?

optional maxColumns?: number

Most column members shown (default 1000). A field with a value per row on columns makes tens of thousands of them and freezes the page; past the cap only the first ones are drawn, totals still count all the data, and the result says so in columnsTruncated. Exports are never cut: they keep every column. 0 or Infinity turns it off.


maxLiveOpenNodes?

optional maxLiveOpenNodes?: number

Default 500,000. While rows stream in under expand-all ('*'), the most row nodes a live-update compute may build. A compute that would build more is not built: the screen keeps its last result, isComputing stays true and engineCompleted is not fired for it. The full result is computed at once when the feed ends (flushAsyncTransactions(), setLoading(false)), for an export, for anything the reader or the app changes (a toggle, a filter, a field), after a synchronous applyTransaction, when no new rows have arrived for about 2 seconds since the last compute was held back, and in a feed that never pauses once the result on screen is 5 minutes old (or older than the live spacing for its cost).

Why: during a long feed every live compute builds the whole open tree, and the last one starts while the previous whole tree is still on screen: two large trees at once. Held back, the last compute starts from a smaller tree. What is counted is the same as for maxRestoredOpenNodes (every row node the grid would keep). Set another number to move the limit; 0 or Infinity turns it off, and every live compute is built as before (the behaviour before 1.11.16). Not used with a serverSource.


maxRestoredOpenNodes?

optional maxRestoredOpenNodes?: number

Off by default: a saved open state is always restored as it was saved. Set a number to opt in: the most row nodes the grid may HOLD for an open state that was put back. It guards against a saved open state on a very large report that builds a tree too big for the tab's memory — loaded again at every visit, the report could never be opened.

What is counted: every row node the grid would keep for that state, not only the rows on screen. Under expand-all ('*') that is every node of the tree, the closed branches' members included (the grid keeps them so that opening one again is instant) — so a state saved after a big "collapse all" still counts the whole tree.

When it applies: to the open rows the grid started with (stateStoring, the default report) or that applyPersistedState / a report put back, at EVERY compute until the reader or the app expands or collapses something (a toggle, expand all, collapse all, setExpandedPaths). So rows streaming in, a wider filter or an added row field that grow the tree past the limit also drop a restored state. The reader's own "Expand all" is never limited. Not used with a serverSource.

Over the limit the worker answers before anything is built: the grid shows every row group closed, replaces the open state with that (so the next save no longer carries it) and calls onRestoredExpansionCollapsed once. Unset, 0 or Infinity: off, and the worker counts nothing.


onAfterPivotCalculate?

optional onAfterPivotCalculate?: (result) => void

Parameters

result

PivotEngineResult

Returns

void

Inherited from

PivotControllerCallbacks.onAfterPivotCalculate


onBeforePivotCalculate?

optional onBeforePivotCalculate?: () => void

Returns

void

Inherited from

PivotControllerCallbacks.onBeforePivotCalculate


onChartStateLoaded?

optional onChartStateLoaded?: (chartState) => void

Parameters

chartState

any

Returns

void

Inherited from

PivotControllerCallbacks.onChartStateLoaded


onComputingChange?

optional onComputingChange?: (computing) => void

isComputing changed: true when a change starts computing, false when its result is shown (B.31). exportData waits for false before it writes. The export waits without a time limit, a slow serverSource.compute included. Print and clipboard run after the wait, so a browser may refuse them once the click that asked for them has expired.

Parameters

computing

boolean

Returns

void

Inherited from

PivotControllerCallbacks.onComputingChange


onError?

optional onError?: (error) => void

Parameters

error

Error

Returns

void

Inherited from

PivotControllerCallbacks.onError


onExporting?

optional onExporting?: (e) => void

Parameters

e

ExportingEvent

Returns

void

Inherited from

PivotControllerCallbacks.onExporting


onFieldGroupChange?

optional onFieldGroupChange?: (e) => void

A field group changed from the screen or changeFieldGroup (Enterprise, B.120); after the change.

Parameters

e

PivotFieldGroupChangeEvent<TRow>

Returns

void

Inherited from

PivotControllerCallbacks.onFieldGroupChange


onFieldMove?

optional onFieldMove?: (e) => void | Promise<void>

Parameters

e

FieldMoveEvent

Returns

void | Promise<void>

Inherited from

PivotControllerCallbacks.onFieldMove


onFieldsChange?

optional onFieldsChange?: (fields) => void

Parameters

fields

PivotField<TRow, PivotCellTemplate, any>[]

Returns

void

Inherited from

PivotControllerCallbacks.onFieldsChange


onLargeExport?

optional onLargeExport?: (info) => boolean | void | Promise<boolean | void>

Before a styled Excel export gives way to the plain one; false cancels (B.23). See ExportOptions.onLargeExport.

Parameters

info

LargeExportInfo

Returns

boolean | void | Promise<boolean | void>

Inherited from

PivotControllerCallbacks.onLargeExport


onLayoutChange?

optional onLayoutChange?: (layout) => void

Parameters

layout

PivotLayoutState

Returns

void

Inherited from

PivotControllerCallbacks.onLayoutChange


onRefresh?

optional onRefresh?: () => void

Returns

void

Inherited from

PivotControllerCallbacks.onRefresh


onRestoredExpansionCollapsed?

optional onRestoredExpansionCollapsed?: (e) => void

The open state that was put back was dropped: the grid would have held nodes row nodes, more than maxRestoredOpenNodes (limit), so the tree would not fit in memory. The grid opened with every row group closed, and that is the state it saves from now on. Called once per grid; tell the reader why ("this report was too large to restore the way it was saved, so it opened collapsed"). nodes counts what the grid would hold, not the rows it would show (see maxRestoredOpenNodes). In development, React StrictMode creates the controller twice, so the callback can fire twice there.

Parameters

e
limit

number

nodes

number

Returns

void

Inherited from

PivotControllerCallbacks.onRestoredExpansionCollapsed


registry?

optional registry?: PivotEngineRegistry


rowKey?

optional rowKey?: PivotRowKeyResolver<TRow>

What identifies a row for applyTransaction: a field name, or a function returning a string or number — the DataGrid's rowKey. Without it rows are matched by object identity, so an update must pass the very object that is in data (mutated in place) and a remove cannot name a bare key.


serverSource?

optional serverSource?: PivotServerSource

Server-side pivot (A4 / G-PIV-01, Enterprise): the server aggregates and the grid lays the answer out. With it, data is not read; build one with pivotServerSource from an Enterprise package.


stateStoring?

optional stateStoring?: PivotStateStoringConfig

Where the grid's layout is persisted between sessions.

Omitted, it is localStorage keyed by gridId — the historical behaviour, kept so an upgrade does not lose anyone's saved layout.


workerUrl?

optional workerUrl?: string | URL