Jspdf-autotable: columnStyles column-specific alignment doesn't apply to corresponding header

Created on 30 May 2018  路  9Comments  路  Source: simonbengtsson/jsPDF-AutoTable

Hello,

I'm attempting to align an entire column (data cells and header), but the following only applies to the data cells:

columnStyles: {
  0: {halign: "right"},
  5: {halign: "right"}
}

The headers for columns 0 and 5 are not right-aligned.

I also tried the following in conjunction with the above-mentioned columnStyles to no avail:

headerStyles: {
  0: {halign: "right"},
  5: {halign: "right"}
}

Any help would be greatly appreciated.

enhancement

Most helpful comment

If anyones looking for an easy fix you can always style a specific column header this way

head: [[{content: 'Services', styles: {halign: 'left'}}, 'Qty', 'Unit Price', 'Subtotal']]

All 9 comments

i also getting this problem :(

Can you provide a runnable example where the issue is reproduced?

i mean using keys or values in columnStyles is working perfectly.
columnStyles: {
0: {halign: "left"},
}
or
columnStyles: {
'title': {halign: "left"},
}

but, when it comes to headerStyles, I cannot specifically align a column.
like
headerStyles: {
0: {halign: "left"},
}
or
headerStyles: {
'title' : {halign: "left"},
}

by the way, i love your plugin. it is really fast.

Got it! Currently you might have to do that with hooks. Whats your use case? Do you think it is better to include the header in the column styles by default? Currently the column styles are only applied for body section I think.

Ok thank you! i get it now. Yes I think it is better to include header in the column styles, it will make things more easier.

Will take a second look at it then before releasing v3 馃憤

Is this resolved? It seems that the column alignment is still not applied to the headers.

If anyones looking for an easy fix you can always style a specific column header this way

head: [[{content: 'Services', styles: {halign: 'left'}}, 'Qty', 'Unit Price', 'Subtotal']]

Still not working for me with the latest v3.5.14. Any alternatives?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cplaiu picture cplaiu  路  3Comments

ayman-aljullaq picture ayman-aljullaq  路  5Comments

sirishasd picture sirishasd  路  4Comments

webdream-fr picture webdream-fr  路  6Comments

ayozebarrera picture ayozebarrera  路  3Comments