Set table width to 100% on PDF export in Datatables

I've been using DataTables a lot these days, it's good. Actually, it's a very good plug-in for displaying data in table (haha), with lots of interaction.

Few and should be implemented feature:

  • Can't export multiple table headers
  • API for table width in PDF Export 
  • Adding header and footer for Excel Export
DataTables uses pdfmake library for its pdf export module.

Sample output of pdf


To make the table width 100%, as per pdfmake documentation we should set its width to "*".

Here it goes:

Edit the datatables JS file, find t.table.widths="auto", change it to t.table.widths="*".

You might want to change the alignment of the table header also:

Find 
tableHeader:{bold:!0,fontSize:11,color:"white",fillColor:"#2d4154",alignment:"center"

Set the alignment to left.
sample output after the tweak



Popular posts from this blog

Auto-calculate your Splinterlands Assets/Income

Creating a Simple Button for Demo

Splinterlands: Water Deck for Beginners