Skip to main content

api.intercept()

Description

Allows intercepting and preventing the inner events

Usage

api.intercept(
event: string,
callback: function
): void;

Parameters

  • event - (required) an event to be fired
  • callback - (required) a callback to be performed (the callback arguments will depend on the event to be fired)

Events

info

The full list of the Pivot internal events can be found here. Use the api.on() method if you want to listen to the actions without modifying them. To make changes to the actions, apply the api.intercept() method.

Example

The example shows how to make all collapsible rows close at the initialization.

// create Pivot
const table = new pivot.Pivot("#root", {
fields,
data: dataset,
config: {
rows: ["studio", "genre"],
columns: [],
values: [
{
field: "title",
method: "count"
},
{
field: "score",
method: "max"
}
]
}
});

//make all rows close at the initialization
table.api.intercept("render-table", (ev) => {
ev.config.data.forEach((row) => (row.open = false));
})

Related articles: render-table