Show Buttons in datatable

Show Buttons in datatable

alderhernandezalderhernandez Posts: 33Questions: 11Answers: 1

hi.
I'm dynamically creating a table by adding the data.,
But I could not add the export buttons

this is mi code

``` var data,
tableName= '#tblDetalleReportes',
columns,
str,
jqxhr = $.ajax(rutaGlobal+"/"+f1+"/"+f2)
.done(function () {
data = JSON.parse(jqxhr.responseText);

            // Iterate each column and print table headers for Datatables
            $.each(data.columns, function (k, colObj) {
                str = '<th>' + colObj.name + '</th>';
                $(str).appendTo(tableName+'>thead>tr');
            });
            // Add some Render transformations to Columns
            // Not a good practice to add any of this in API/ Json side
            data.columns[3].render = function (data, type, row) {
                 return data;
            }
            $(tableName).dataTable({
                "data": data.data,
                "columns": data.columns,
                dom: 'lfrtip',
                buttons: [
                    'copyHtml5',
                    'excelHtml5',
                    'csvHtml5',
                    'pdfHtml5'
                ],
                "pagingType": "full_numbers",
                "lengthMenu": [[10, -1], [10, "Todo"]],
                "language": {
                    "emptyTable": "No hay datos disponibles en la tabla",
                    "lengthMenu": '_MENU_ ',
                    "search": '<i class=" material-icons">search</i>',
                    "loadingRecords": "",
                    "paginate": {
                        "first": "Primera",
                        "last": "Última ",
                        "next":       "Siguiente",
                        "previous":   "Anterior"
                    }
                },

                "fnInitComplete": function () {
                $('#tblDetalleReportes').on( 'init.dt', function () {
                    var totalAcumulado = 0;
                    obj = $('#tblDetalleReportes').DataTable();
                    obj.rows().data().each( function (index,value) {
                       //totalAcumulado += parseInt(obj.row(value).data().PUNTOS.replace(".000000",""));

                    });
                    //$('#spanTotal').text(totalAcumulado);
                }).dataTable();
                }
            });

```
im using this library
but does'n work

//code.jquery.com/jquery-1.12.3.js
https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js
//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js
//cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js
//cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js

Replies

This discussion has been closed.