Javascript array want to create custom format for given input to pdfmake

Viewed 35
my_values = [];
my_values.push('0','1','2','3','4','5','6');
column1 = ['0','1','2','3','4','5','6'];
var docDefinition = {
  content: [
  {
    layout: 'lightHorizontalLines', // optional
    table: {
      //headers are automatically repeated if the table spans over multiple pages
      // you can declare how many rows should be treated as headers
      headerRows: 1,
      widths: [ '*', 'auto', 100, '*','*','*','*' ],
      body: [
      column1,my_values
      ]
    }
  }]
};

The above code is working fine to generate pdf, but my problem is to parse data which loaded from datatable like this.

var table = $('#example').DataTable();
var data = table.rows().data();

The data is shown in the console log like this:

It is log of data table array[array[],array[]]

I want the array like this to give input into pdfmake to row content.

  column1 = ['0','1','2','3','4','5','6'];
  var docDefinition = {
            content: [
            {
            layout: 'lightHorizontalLines', // optional
            table: {
            //headers are automatically repeated if the table spans over multiple pages
            // you can declare how many rows should be treated as headers
            headerRows: 1,
            widths: [ '*', 'auto', 100, '*','*','*','*' ],
            body: [
                column1,['0','1','2','3','4','5','6'],['0','1','2','3','4','5','6']
                // here i want like this.
                column1,rows
                // where rows is having array like this to format console log to this. [''],[''],[],[]    
            ]
            }
            }
            ]
        };

Dear community

  1. How to approach to good solution on this.

How can the console.log data converted into array format so that can be read easily into body content of pdfmake docDefination?

0 Answers
Related