export PDF : don't print hidden elements
export PDF : don't print hidden elements
Hello - I have a problem with hidden elements still showing in my PDF export, and I don't know how to get them invisible.
I have hidden input elements and "labels+radio" in my table as :
...
<tr class="printable">
<td>NAME</td>
<td><span class="spaneses">NO </span>
<div class="alleses dalleses uk-button-group data-uk-button-radio uk-hidden" id="infall">
<label class="alleses uk-button uk-hidden" id="lnullinall"><input type="radio" class="alleges ballets uk-hidden" value="" name="binall" id="nullinall" style="display:none;"/>NO</label>
<label class="alleses uk-button uk-hidden" id="lnullinall"><input type="radio" class="alleges ballets uk-hidden" value="" name="binall" id="nullinall" style="display:none;"/>Tracce</label>
<label class="alleses uk-button uk-hidden" id="lnullinall"><input type="radio" class="alleges ballets uk-hidden" value="" name="binall" id="nullinall" style="display:none;"/>SI</label>
</div></td></tr>
<tr class="printable">
<td>NAME</td>
<td><span class="spaneses">blabla </span>
<input type=text class="texteses uk-hidden" ></input>
</td></tr>
...
classes alleses, ballets and textiles are DOM hidden (using uk-hidden), they are visible only on edit.
Now I have defined the print and pdf buttons:
...
buttons: [
{extend: 'print',
exportOptions: {
columns: ':visible',
stripHtml: false,
rows: '.printabled'
},
text:'print'
},
{extend: 'pdf',
exportOptions: {
columns: ':visible',
stripHtml: true,
rows: '.printabled'
},
text:'PDF'
}
],
...
The print button works as intended - It prints what is shown on the web page at that moment. I get the columns and rows I want printed, and while I have not yet understood how to format and keep some colors on my export - I can leave it for now like this.
The PDF button has a problem: It shows the labels (NOTracceSI) of my radio buttons , that are normally hidden, as well as the correct value - while the input fields, which are also hidden are not visible in the PDF (which is what I want)
like this (first the value which is in the Span, then the labels)
...
NONOTracceSI
NOTracceSI
SINOTracceSI
...
I understand why the input fields (or the buttons themselves) do not show, since I said stripHTML : true.
How can I make the labels stay invisible ? I guess I must use the customize option, but everything I have tried has failed miserably, to the point I don't what to write there anymore.
If somebody can point me in the correct direction with an example or some explanations I will be very grateful
Answers
The problem is that Buttons just strips the HTML tags from the
innerHTML
of the element. As sure it doesn't do anything aboutdisplay:none
elements. You would need to use a custom formatting function to handle that.Not ideal I realise, but I don't currently know of a better way to provide the export.
Allan