Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reset columns and rows after initial view #729

Closed
eformx opened this issue Jun 21, 2017 · 8 comments
Closed

Unable to reset columns and rows after initial view #729

eformx opened this issue Jun 21, 2017 · 8 comments

Comments

@eformx
Copy link

eformx commented Jun 21, 2017

I load the pivotUI with json data and works fine.

$("#chart").pivotUI(arr_found, {
            rows: ["Segmentation"],
            cols: ["Transferred"],
         });

I have a button and on click I want to change the layout but it doesn't clear the old view.

$(document).on('click', ".btn_pivot", function (e) {
//arr_found is my global json data
$("#chart").pivotUI(arr_found, {
            rows: ["Segmentation", "Transferred"]
         });

});

So what I would like to do is have pre-configured layouts so the pivot can be changed from buttons. Possible? How?

@nicolaskruchten
Copy link
Owner

This example explains how to use the overwrite parameter of pivotUI() to accomplish what you want: http://nicolas.kruchten.com/pivottable/examples/save_restore.html

@eformx
Copy link
Author

eformx commented Jun 21, 2017

Hi Nicolas,

Actually I don't want to save the config, I have users that don't understand pivots...so I would like 3 buttons with the 3 layouts in the click events. Hit a button...configure the layout from the same data. Currently the only way I have been able to get to work is using JQuery remove of the div and then append a new div and re-initalize it. But that just doesn't seem a perfect solution?

@nicolaskruchten
Copy link
Owner

nicolaskruchten commented Jun 21, 2017 via email

@eformx
Copy link
Author

eformx commented Jun 22, 2017

Your solution only works if the config file can be built and stored in script; which I haven't seen...I have users across the country (Canada), so the cookie retrieval suggestion does not work. So currently I am going for the following super simple solution:

$("#chart").remove();        
        $(".some_charts").append("<div id='chart'></div>");        
        $("#chart").pivotUI(arr_found, {
            rows: ["Segmentation"],
            cols: ["Transferred"]
        });

@nicolaskruchten
Copy link
Owner

I'm 99% sure you just need to do this to accomplish what you want:

$("#chart").pivotUI(arr_found, {
            rows: ["Segmentation"],
            cols: ["Transferred"]
        },
        true // <-- this is the overwrite parameter you need to set to true!
);

@nicolaskruchten
Copy link
Owner

re your comment that "only works if the config file can be built and stored in script" ... in the example you gave above you have this, the config object is just {rows: ["Segmentation"], cols: ["Transferred"]}.

@nicolaskruchten
Copy link
Owner

Check out the documentation for the overwrite parameter here: https://github.com/nicolaskruchten/pivottable/wiki/Parameters#pivotuiinput-options-overwrite-locale (note: it's not part of the config, it's a separate parameter to pivotUI()

@eformx
Copy link
Author

eformx commented Jun 22, 2017

Okay that works...I saw that; but without any implementation guidance on the site, I couldn't figure out where to put it. So for anyone else that needs to know where it goes here it is...

              $("#chart").pivotUI(arr_found, {
                    rows: ["Segmentation"],
                    cols: ["Transferred"]
                }, true); 

@eformx eformx closed this as completed Jun 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants