7

mPDF: Hide table row (CSS display:none) not work. Do you have any suggest? My code:

<table align="center">
    <tr style="display:none">
        <td valign="top" align="left">InfoOption1:</td>
        <td valign="top" align="left" colspan="2">#InfoOption1</td>
    </tr>
</table>
Falko
  • 17,076
  • 13
  • 60
  • 105
Zeigen
  • 126
  • 2
  • 7

2 Answers2

6

I feel very dirty for posting this suggestion, but it's the best I got working:

<tr><td>...</td></tr>
<div style="display: none;">
    <tr><td>...</td></tr>
</div>

The DIV is the working part. Luckily, html validnes for seo isnt relevant for mPDF

Martijn
  • 15,791
  • 4
  • 36
  • 68
  • This is a good workaround but I can't use this as my HTML is not only used for mPDF, I can add classes but can't play with the DOM. Did you find another way since ? (btw I have to hide a TD, actually a column...) Here is supported CSS : https://mpdf.github.io/css-stylesheets/supported-css.html Therefore I hid the borders and hid the td content. But there is still an empty space... better than an empty visible cell – Nicolas Thery Apr 06 '17 at 09:11
  • Haha this is a while ago, I don't know how to fix your case. Maybe height=0 & overflow hidden? Or a negative margin bottom – Martijn Apr 06 '17 at 09:19
  • problem is more the width than the height, having it not visible is fair enough for me :) even if width is taken. But it worth trying a negative margin right. next time... – Nicolas Thery Apr 06 '17 at 14:52
1

It works if you enclose the row you want to hide inside a Div. The div will have a class which have declared hidden property.

<div class='hide_this_row'>
  <tr> 
    <td>...</td>
  </tr>
</div>

<!-- CSS file will look like this -->
<style>
  .hide_this_row{
    display :none;
  }
</style>