nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

Firefox print table bug -> missing HTML tags #248

Closed widdi closed 9 years ago

widdi commented 9 years ago

Hi, I encountered a problem trying to print (or print preview) a pivot table. On most tables of my database it works fine, but on one particular table the firefox print functionality hides parts of it.

Details on my pivottables: I'm using the following Pivotatbles libraries d3_renderers.js, gchart_renderers.js and pivot.js (all downloaded on July 24th 2014). I use the following code to call the pivot table with ui:

 var options = {
        rows: defaultRowsNames,
        cols: defaultColsNames,
        vals: defaultValuesNames,
        rendererName: defaultRenderer
        // although the use of google charts would require an extension of the standard renderers
        // with google renderers here in the options, we must not do this here, because we already
        // did that in our localization library pivotables.DATE.pivot.de.js.view
    }

    data.unshift(columnNames);

    if (<%= $usePivotUI %>) {
        options.aggregatorName = defaultAggregator;
        options.menuLimit = 500;
        $("#table-view").pivotUI(data, options, false, "de");
    } 

As I mentioned above, around 20 other tables are shown/printed fine this way, but one isn't. The table itself is nothing special, its not the longest (around 100 rows, 4 columns, using sum aggregator).

So my first thought was this is a Firefox bug (since it works fine on Safari and Chrome) and I can do nothing about it, but then I noticed a little suspicious detail: Using the Firefox developer tools I saw the following in your pivot tables' HTML:

<table class="tbg" id="table-view" cellpadding="0" cellspacing="0" border="0">
    <table cellpadding="5">
        <tbody>
            <tr>
                <td>
                    ...
                </td>
            </tr>
        </tbody>
    </table>
</table>

So your using neste table tags and I wondered if this might be the problem, so I added the tbody, tr and td tags for the first table tag manually getting

<table class="tbg" id="table-view" cellpadding="0" cellspacing="0" border="0">
   <tbody>
      <tr>
         <td>
            <table cellpadding="5">
               <tbody>
                  <tr>
                     <td>
                        ...
                     </td>
                  </tr>
               </tbody> 
            </table>
         </td>
      </tr>
   </tbody>
</table>

and it worked fine!

That's why I'm writting this to you. It seems Firefox's print functionality needs the additional tags to work properly in every case. So would you please add them to your pivot tables tool? Or maybe you have an idea how to fix my problem another way.

It's not very urgent, but I want to fix that bug. It haunts my dreams ;-)

Greetings, widdi

nicolaskruchten commented 9 years ago

Thanks for this very detailed bug report!

Unfortunately, however, I don't believe this is a problem with the PivotTable.js library but rather the code in the application around it. This library's output is only the <table cellpadding="5"> but not the table around it...

Can you confirm?

jobinspr commented 2 years ago

this issue still exists on the firefox 98 version