Print and exportOptions.columns - BUG
Print and exportOptions.columns - BUG
Hello @allan
In the print
, with the exportOptions.columns
set, I have wrong class set in the result columns.
Ex: I put 5 columns, the first with class = select-checkbox, the second aligned to the right, the third centered and the other unformatted
But in ExportOption, I will only print columns 2 and 5
As a result I will have column 2 with class select-checkbox (as it refers to vector 0 of the columns) and column 5 right-aligned (because the vector points to the second column)
In short, the data
is different from the columnClasses
The wrong line is this: https://github.com/DataTables/Buttons/blob/8925bf655f1ee4128f63ca1a77bb2077228d750c/js/buttons.print.js#L106
This question has an accepted answers - jump to answer
Answers
Can you give me a link to a page showing the issue please?
If you want to export all but the first column use
columns: ':gt(1)'
.Allan
Hello @allan
Here is the sample: https://jsfiddle.net/rodriformiga/u78genkx/6/
See, the first column in the print page have the class "select-checkbox" but the correct column is excluded from the print view. The same about the column "Data", right-aligned in the datatable, but in the print the column right-aligned is "Valor"
Got it! Thanks for the test case. I've committed the fix here and you can see it with your example here.
Regards,
Allan
Hey, @allan
Sorry, but I think you forgot something. The indexes of the column:
Doh! Thanks for pointing that out - I only checked for it stripping classes, which it of course did there. Proper fix here. Updated example.
Allan
No problems @allan
And... Sorry again... I think this solution will not work either...
In my last comment I put the code that worked for me.
I put a
console.log
after this code to see the correct classes of each column, and the column "Data" needs to be right-aligned in the print page to work correctly.In your last code, the
columnClasses
is an array of 1'sThis time I've really got it!
What a mess - sorry!
Allan
Yeahh @allan
Thanks... Now, all it's Ok!
Rodrigo