Search code examples
javascriptjspdftabulator

Get DataKey property from Tabulator Object


I have a Problem with Tabulator in common with jspdf. I created a Tabulator table with about 20 columns like this...

const tblErgebnis = new Tabulator('#tblErgebnis', {
    history: true,
    data: tblData,
    movableColumns: true,
    layout: 'fitColumns',
    resizableColumns: true,
    responsiveLayout: 'hide',
    layoutColumnsOnNewData: true,
    columns: [
      {
        title: 'Region',
        field: 'R',
        align: 'center',
        sorter: 'string',
        visible: false,
        headerDblClick: function(e, column) {
          tblErgebnis.toggleColumn('R');
        },
      }
    ]
});

This table is displayed on a website and now I am trying to get this table printed on a PDF.

This works so far but my problem is the cellwidth in the printed PDF. I read about the dataKey possibility and set the columnstyles for the specific column. But now I don't know ho to get the dataKey in the Tabulator Object to reach it from jspdf function. The need of this is because not every column can be select oder deselect and the sequence of the columns ca be changed.


Solution

  • Have a look at the PDF Download Documentation there are a number of properties that you can pass into the download function config object to allow direct manipulation of the generated PDF

    jsPDF - an optional object that will be passed into the jsPDF constructor and can take any of the standard jsPDF options

    autoTable - an optional object that can be used to configure advanced styling on the table if needed, this can take ay of the standard AutoTable options

    documentProcessing - an optional callback that is passed the jsPDF document object after the auto-table creation to allow full customisation of the PDF, see the jsPDF documentation for a full list of methods that can be called on this object