Colvis and Responsive how to export toggle information ?

Colvis and Responsive how to export toggle information ?

lenamtllenamtl Posts: 265Questions: 65Answers: 1

I'm using Colvis, Responsive with export buttons.
It's look like responsive toggled information (child) is considered as not visible column and cause problem when using the export function with[':visible'] so if you are in mobile device export only visible you will end with one or two columns.

Even if all row are toggle open these are considered as not visible
Here is my code and it's exporting only the non toggle info

"bProcessing": true,
    dom: 'Blfrtip',
    buttons: [
                {
                    extend: 'colvis',
                    text: 'show hide columns',
                    titleAttr: 'show hide columns',
                    title: 'show hide columns',
                    collectionLayout: 'two-column', 
                        columns: [':visible:not(.not-export-col)'],
                },
                {
                    extend: 'excelHtml5',
                    text: 'excel',
                    titleAttr: 'excel',
                    title: 'my title',
                        exportOptions: {
                                columns: [':visible:not(.not-export-col):not(.hidden)'],
                        }
                }, 
            ],

I use to fix that problem (don't remember how) but now the problem is back so I need to fix it.
There are a lot of question about this problem since a few years and no solution found....

Any solution is welcome...

Thanks

Answers

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    I'm thinking about a solution

    Let say when a column get visible the script add a class name to the visible columns
    so I could change the export and colvis value

    columns: [':visible:not(.not-export-col)'],
    to
    columns: [':myvisibleclass:not(.not-export-col)'],

    will it also export the toggle responsive value?

    Is this make sense?

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    I'd like to mention that I'm using button Colvis.
    Do I need to edit the core code or just colvis script?

    Thanks

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    I'm using this hack for now and this is working ok
    https://datatables.net/forums/discussion/46118/how-to-add-an-action-to-the-api

This discussion has been closed.