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:
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
- 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?
![It is log of data table array[array[],array[]]](https://i.stack.imgur.com/LlFMu.png)