Skip to main content

getTable()

Description

Gets access to the underlying Table widget instance in the Pivot table

This method is used when there's a need to access the underlying Table widget instance in Pivot. It provides direct access to the Table functionality allowing for operations such as data serialization and exporting in various formats. The Table API has its own api.exec() method that can call the open-row, close-row, export events. Usage examples with the events you can see here: Expanding/collapsing all rows, Exporting data

Usage

getTable(wait:boolean): Table | Promise;

Parameters

wait - defines if to wait until Table API is available in Pivot (necessary when Table API is used during Pivot initialization). If the value is set to true, the method returns a promise with Table API.

Example

In the example below we get access to the Table widget API and trigger the Table exportevent with the button click using the api.exec() method.

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

// access table instance
let table_instance = table.getTable();

function toCSV() {
table_instance.exeс("export", {
options: {
format: "csv",
cols: ";"
}
});
}

const exportButton = document.createElement("button");

exportButton.addEventListener("click", toCSV);
exportButton.textContent = "Export";

document.body.appendChild(exportButton);