Header and body column order mismatched when using exportOptions columns for print button

Header and body column order mismatched when using exportOptions columns for print button

stokes_dkstokes_dk Posts: 1Questions: 0Answers: 0

Link to test case: https://codepen.io/stokes_dk/pen/yyBYXYV
Debugger code (debug.datatables.net): opovot
Error messages shown:
Description of problem:
Use column visibility to hide the Position column then press the print button. In the output, the order of the header is Name, Position, ... Salary; the order of the body rows is Name, Office, ... Position.

Name Position Office Age Start date Salary
Ashton Cox San Francisco 66 2009-01-12 $86,000 Junior Technical Author
Cedric Kelly Edinburgh 22 2012-03-29 $433,060.00 Senior Javascript Developer

This happens when exportOptions for the print button are specified as:

exportOptions: {
    columns : [ ':visible', '.always-print' ]
}

and there is a hidden table column with the class 'always-print', e.g.:

<thead>
        <tr>
            <th>Name</th>
            <th class="always-print">Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
</thead>

What I expected is that it would print only the visible columns but always include the Position column regardless of its visibility; in other words, :visible OR .always-print. What happens is that Position is always included but its placement in the header does not match its placement in the body rows.

Everything works as expected when the Position column is visible. When the Position column is hidden, this problem occurs.

I couldn't find anything in the docs for column-selector that says explicitly what should happen when ':visible' is used with a selector like '.always-print'. Some clarification in the docs would be helpful but presumably it is not intended to operate one way for the header and a different way for the body rows.

The same problem occurs with the csv export button.

Replies

Sign In or Register to comment.