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.33k stars 1.07k forks source link

How to save pivottable.js filter settings? #1316

Open sergiologgan opened 1 year ago

sergiologgan commented 1 year ago

I need to load the pivottable filter settings that I made earlier,

In the example below, I just unchecked "Female" and notice that on the left side, a record was inserted in the item "exclusions", as it indicates the path that was changed

My question is, after refreshing the page, how can I load this configuration I made earlier?

When I refresh the page, this checkbox is checked again, which it shouldn't

This link shows an example of pivottablejs working, but doesn't show how to save the filter changes and so on.

In pivottablejs documentation I didn't find the answer to my question

zhmIP

Below this script loads the data, but how can I apply the previously saved data in this script? For example, if I unchecked some checkbox, did I move it from one place to another?

This code is on github documentation

$(function () {
    $.getJSON("mps.json", function (mps) {
        $("#output2").pivotUI(mps, {
            onRefresh: function (config) { 
                var config_copy = JSON.parse(JSON.stringify(config));
                //delete some values which are functions
                delete config_copy["aggregators"];
                delete config_copy["renderers"];
                //delete some bulky default values
                delete config_copy["rendererOptions"];
                delete config_copy["localeStrings"];
                $("#output").text(JSON.stringify(config_copy, undefined, 2));
            }
        });
    });
});
ausfas commented 1 year ago

I'm waiting for a solution too

juanmantelli commented 1 year ago

Hi, I am using this example deleting nothing in the config_copy, because I need them, and it works!