I am working with vuejs - DataTable and when I want to generate my report of the tables in pdf I get an error.
while if I generate an excel report it works correctly
my form
<table id="example1" class="table table-bordered table-striped responsive">
<thead>
<tr>
<th>Id_categoria</th>
<th>Categoria</th>
<th>Fecha(s)</th>
<!--<th>Botones(s)</th>-->
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th>Id_categoria</th>
<th>Categoria</th>
<th>Fecha(s)</th>
</tr>
</tfoot>
</table>
my script
<script>
import axios from "axios";
import $ from 'jquery';
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
export default {
mounted() {
this.getUsers();
},
methods: {
getUsers() {
axios
.get("https://sistema-control-inventario.herokuapp.com/categoria/")
.then((response) => {
var table = $("#example1").DataTable({
"responsive": true, "lengthChange": true, "autoWidth": false,
"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
"language": "",
data: response.data,
columns: [
{ data: "id_categoria" },
{ data: "categoria" },
{ data: "fecha" },
// { defaultContent : '<button type="button" class="editar btn btn-primary"><i class = "fa fa-pencil-alt"></i></button> <button type="button" class="eliminar btn btn-danger" data-toggle="modal" data-target="#modalEliminar"><i class="fas fa-dumpster-fire"></i></button>'}
],
}).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)')
//obtener_data_editar('',table);
}).catch((error) => console.log(error.response));
},
},
};
var obtener_data_editar = function(tbody,table){
$(tbody).on("click", "button.editar", function(){
var data = table.row($(this).parent('tr')).data();
console.log(data)
})
}
</script>
the page looks something like this
I would be grateful if you could help me to generate the pdf with this button and with the data that are in this one.
Thank you very much.
pd: i am using vue 3 cli
