| sidebar_label | api.intercept() |
|---|---|
| title | intercept Method |
| description | You can learn about the intercept method in the documentation of the DHTMLX JavaScript Pivot library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Pivot. |
@short: Allows intercepting and preventing the inner events
api.intercept(
event: string,
callback: function,
config?: { tag?: number | string | symbol }
): void;event- (required) an event to be firedcallback- (required) a callback to be performed (the callback arguments will depend on the event to be fired)config- (optional) an object that stores the following parameter:tag- (optional) an action tag. You can use the tag name to remove an action handler via thedetachmethod
:::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.
:::
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));
}, {tag: "render-table-tag"});Related articles: render-table