question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Colspan in First Row

See original GitHub issue

I am using version 3.1.1 and my table needs 4 columns but the first row of my form has only 2 columns so I need to use colspans in the first row. AutoTable doesn’t seem to do colspans right if the first row doesn’t have all the columns there will be. If my first row contains 4 blank cells, everything works fine but I get an unnecessary row on the top of my table. Here’s some code that demonstrates the issue:

var doc = new jsPDF();
var desiredDefinition = [
  [{"content":"Field 1","colSpan":2}, {"content":"201901300654","colSpan":2}],
  [{"content":"Field 2"},{"content":"Field 3"},{"content":"Field 4"},{"content":"Field 5"}],
];
doc.autoTable({ body: desiredDefinition }); 

var workaroundDefinition = [
  [{"content":""},{"content":""},{"content":""},{"content":""}],
  [{"content":"Field 1","colSpan":2}, {"content":"201901300654","colSpan":2}],
  [{"content":"Field 2"},{"content":"Field 3"},{"content":"Field 4"},{"content":"Field 5"}],
];
doc.autoTable({ body: workaroundDefinition }); 
doc.save("table.pdf");

Here’s a codepen with the issue: https://codepen.io/sirhcybe/pen/rgpKEJ

I played around with the columns property but couldn’t find any way to tell AutoTable how many columns I need without creating an extra row.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
simonbengtssoncommented, Aug 9, 2019

Fixed in v3.2

1reaction
sirhcybecommented, Jun 4, 2019

I’m taking a look into this. Looks like inputParser line 179 might be the place to put in a fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Colspan on cell in one row seems to prevent setting TD width ...
I want to force the first cell to only be as wide as the image. Here is a sample: <html> <body> <table> ...
Read more >
Table Rowspan And Colspan In HTML Explained (With ...
Both colspan= and rowspan= are attributes of the two table-cell elements, <th> and <td> . They provide the same functionality as “merge cell”...
Read more >
HTML Table Colspan & Rowspan - W3Schools
HTML tables can have cells that span over multiple rows and/or columns. ... To make a cell span over multiple columns, use the...
Read more >
colSpan in first row causes error or display problems #633
They must be defined all cells of table. This is a feature (probably poor, but it is so.).
Read more >
suddenly added colspan when adjusting to mobile screen
suddenly added colspan when adjusting to mobile screen ... However, the first <td> automatically generated colspan="2". ... Line: 793
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found