Colspan in First Row
See original GitHub issueI 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:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in v3.2
I’m taking a look into this. Looks like inputParser line 179 might be the place to put in a fix?