KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Pivot: how to make Collaps all/Open all buttons #3238

Open Eugene opened this topic on on Feb 3 - 3 comments

Eugene commented on Feb 3

Hi, the question is in subj. Ho to make a button that will open or close all items?

Sebastian Morales commented on Feb 5

You can inspect the expand/collapse icons to see their class names, attributes, etc and perform a javascript command document.querySelectorAll to select all of them, then loop through them and call icon.click().

Eugene commented on Feb 5

Ok... I just thought it is already implemented somehow to the pivot table widget. By the way a good feature...

Eugene commented on Feb 5

Maybe it could be useful for somebody

document.addEventListener('DOMContentLoaded', function () {
        document.getElementById('closeAllButton').addEventListener('click', closeAll);
        document.getElementById('openAllButton').addEventListener('click', openAll);


        function openAll() {
            var icons = document.querySelectorAll('.pivot-exp-col.fa-plus-square');

            icons.forEach(function (icon) {
                icon.click();
            });
        }

        function closeAll() {
            var icons = document.querySelectorAll('.pivot-exp-col.fa-minus-square');

            icons.forEach(function (icon) {
                icon.click();
            });
        }
    })

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

Pivot