jsPDF-AutoTable icon indicating copy to clipboard operation
jsPDF-AutoTable copied to clipboard

Table Header with several rows and Footer

Open Grendizr opened this issue 10 years ago • 8 comments

Hi.

I tried to reopen a related issue which is closed, but didn't seem to work, so here I am.

I have a table with header made of two rows. I want both rows to be exported as part of the header, with same style. Currently only the last header row is exported.

I have updated you basic table from the sample. Note that the color display down here is not correct as both row headers should be displayed the same way.

On top of that, the table footer <tfoot>...</tfoot> does not seem to be exported at all

Thanks in advance for your quick feedback.

Grendizr avatar Aug 16 '16 12:08 Grendizr

Have you tried using the hooks? It might be a bit tricky but should be possible both having two rows as header and to add a footer. Lets keep this issue open as a feature request though. How would you like the api to look like for this?

simonbengtsson avatar Aug 18 '16 14:08 simonbengtsson

I haven't figured out a way to do it properly with the hooks.

Would make much more sense to include it as default. Doesn't sound too complicated. I would replace the property headerRow:Row with headerRows:Row[].

The headerRow is used to defined the columns of the table, so you can keep doing that by using the last header row of the array. And on top of that you add all previous rows as defined in original table.

In order to not have any breaking changes you can check the headers parameter which is provided and create a single or multiple row array.

For footer, just grab the <tfoot> from the original table if there is one and add it as is in the generated table...

What do you think?

Grendizr avatar Aug 19 '16 10:08 Grendizr

Sounds good, will probably make it that way when and if it is implemented. Feel free to submit a PR for it.

If want pointers to how to draw multiple headers, I made an example a while back here: http://stackoverflow.com/a/35382414/827047. Basically what I did was first increasing the height of the default header, then simply draw the secondary header in the space that was freed because of it.

Here is a jsfiddle: https://jsfiddle.net/someatoms/tbz8p79j/6/ The pdf ends up something like this:

image

simonbengtsson avatar Aug 19 '16 13:08 simonbengtsson

Thanks for the details. It looks good except some css details cause it almost look like a regular row with the alternate colors.

Grendizr avatar Aug 21 '16 10:08 Grendizr

You should just be able to set the fill color to the same blue to achieve the same styling.

simonbengtsson avatar Aug 21 '16 15:08 simonbengtsson

Support for multiple headers and footers now in master. Will be released in version 3.0.

simonbengtsson avatar Jan 25 '17 16:01 simonbengtsson

Is there a timeline for for when 3.0 will be released?

padryn avatar Apr 13 '17 17:04 padryn

In a few days hopefully!

simonbengtsson avatar Apr 13 '17 19:04 simonbengtsson