Skip to content

Latest commit

 

History

History
68 lines (54 loc) · 1.97 KB

File metadata and controls

68 lines (54 loc) · 1.97 KB
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.

api.intercept()

Description

@short: Allows intercepting and preventing the inner events

Usage

api.intercept(
    event: string,
    callback: function,
    config?: { tag?: number | string | symbol } 
): 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)
  • 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 the detach method

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));
}, {tag: "render-table-tag"});

Related articles: render-table