nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

Get current aggregator name from pivotUI #756

Open MarcoAbi opened 7 years ago

MarcoAbi commented 7 years ago

Hello, thanks for the great work! Wonderful library. I need this use-case in which the user needs to choose its pivot via pivotUI, than save it and see the result directly with pivot (not ui) as "saved view".

What I'm trying to do is export pivotUI config via onRefresh function call and then use the configuration (properly modified) in order to use it into pivot. The configuration is also serialized and saved to save user setup. However, some configuration cannot be moved (like the aggregator used or the Aggregator or Renderer).

Is there a way to know the renderer and aggregator currently used? My idea is to use the aggregator to set the correct value with pivot such as:

var currentRendererFromPivotUI = "Table"; // "Table" obtained somehow form pivotUI
var rendererForPivot =  utils.renderers[currentRendererFromPivotUI];

Thanks a lot! Marco

nicolaskruchten commented 7 years ago

Glad you like this library!

The onRefresh callback will provide the entire configuration, including the aggregator name. See for example: https://pivottable.js.org/examples/onrefresh.html

sujeetsks commented 7 years ago

I am not getting what mps.json here. What it stores currently? I have passed $.pivotUtilities.tipsData instead of that but it did not work.

nicolaskruchten commented 7 years ago

@sujeetsks please do not add unrelated comments to pre-existing issues, but rather create new issues.

To answer your question, "mps.json" and $.pivotUtilities.tipsData are both sample datasets used for the examples. You need to replace these with your own data, in a compatible format, following the documentation here: https://github.com/nicolaskruchten/pivottable/wiki/Input-Formats