Quantcast
Viewing all articles
Browse latest Browse all 82036

column options modified for export?

I have my columns for buttons exports defined as arrays of pointers to the columns. These are combinations of visible and hidden columns. I'd like to be able to toggle a colvisGroup and in doing so, also remove those columns from being included in the export.

So I figured out how to use an action for the button on the colvisgroup to modify an array I'm using to store the column pointers.

{
                        extend: 'colvisGroup',
                        text: 'Volume',
                        hide: [18,19,20,21],
                        action: function(e, dt, node, config) {
                            var hidearray = [18,19,20,21];
                            agentExportCSV = agentExportCSV.filter(item => !hidearray.includes(item));
                            $.fn.dataTable.ext.buttons.colvisGroup.action.call(this, e, dt, node, config);
                        }
                    }

This correctly removes the columns it's hiding from the array and still executes the intended hiding action for the column group. However, no matter what I try for a callback on the columns definition on the CSV export, it seems to store that on initialization of dataTables rather than when executed.

{
                text: 'CSV',
                extend: 'csvHtml5',
                exportOptions: {
                    columns: function() {
                        return getExportColumns('agentExportCSV');
                    },
                    modifier: {
                        page: 'current'
                    }
                },
                filename: function() {
                    return getLocationName();
                }
            }

I've confirmed the columns array it's returning to the exportOptions columns is the new modified version but it always exports the full columns. Any way I get achieve what I need?


Viewing all articles
Browse latest Browse all 82036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>