Accessing inner data pivot table

Hi,

Is it possible to to access the Pivot’s internal aggregated dataset, apply custom filtering to those aggregated values, and then push that filtered result back into the Pivot table?

Kind regards,

Nick

For anyone who might need it: I created a small function to handle this.

export function getPivotTable(pivot) {

      return pivot.queryView({ view:"treetable" }) || pivot.queryView({ view:"datatable" });
}

Hello Nick,

To access the inner table you can use pivot.queryView({ view: "treetable" }), like you described. However, the pivot table does not have a “datatable” view, only two “treetable” and a “chart”. Then, to apply custom filter on top (or instead) of pivot’s filters, you can call the filter method on the internal treetable and provide your own filter callback function.

Here is an example with everything combined: Code Snippet

In this example, the custom filter (“greater than” with a combobox containing columns) is applied to the table. The aggregated dataset doesn’t contain distinct field names, but the IDs and titles of columns can be collected into options for a UI filter.

The “structure” state stores such things as rows, columns, values, etc. - components of the pivot table. It’s value is observed to update the combo box. More on pivot’s state here.

The custom table class applies filter on initialization - to ensure its proper execution when switching between pivot’s views. The standard table is replaced with the override property.

The chart filtering hasn’t been implemented yet - I will provide a full example including it a bit later.

Here is a full example, now with chart filtering implemented: Code Snippet

Similarly to the table, chart class was replaced with a custom one to ensure correct loading and filtering order. The “mode” state is also observed now to update the combo box with columns. The function to create combo box entries was also modified to work with the chart. Combo options use array indices to create their IDs - but null, false, and 0 cannot be used as identifiers, so they are converted to strings.