GrinnS
GrinnS

Reputation: 143

JsPdf Auto Table : Customize headers with colspan

I need to export a few tables to PDF format. I decided to use jspdf-autotable but I can't find a way to customize my header. I need to do this in the header style :

 _________________________________________
 |__________|______________|_____________|
 |____|_____|___|__|___|___|___|___|__|__| 
 |____|_____|    ... (content)
 |____|_____|    ... (content)

The first line is my problem, as headers are define differently, and I cant find a way to do this through the "drawHeaderCell" method. Do u know a way to do this ?

Thank you

Upvotes: 0

Views: 2575

Answers (1)

Simon Bengtsson
Simon Bengtsson

Reputation: 8151

To get such a result you could implement the drawHeaderCell hook something like this:

    drawHeaderCell: function(cell, data) {
        if (data.column.dataKey === 'id' || data.column.dataKey === 'first_name' || data.column.dataKey === 'email') {
            cell.width = data.table.width / 3;
        } else {
            return false;
        }
    }

Doing rowspans and colspans are quite complicated at this stage with jspdf-autotable. There is an example for how they could be implemented in the repo however.

Upvotes: 2

Related Questions