Dont work buttons Export (CSV-PDF-COPY-EXCELL)

Dont work buttons Export (CSV-PDF-COPY-EXCELL)

monsalvezmonsalvez Posts: 2Questions: 0Answers: 0
edited October 2016 in Free community support

Good afternoon Allan,

Some months ago buy your APIs and export buttons worked me. I give you an example of my code:

#
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor },
{
extend: 'print',
text: 'Print',
columns: ':visible',
autoPrint: true,
orientation: 'landscape',
pageSize: 'A4',
},
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5',
'pageLength'
]
} );
#

With my web application, now dont working this code.
Please, I need help I searched a lot and have tried everything:

The code also but it does not work

https://editor.datatables.net/examples/extensions/exportButtons.html


This is my code .js

//////////////////////////////////

function getGET(){
   var loc = document.location.href;
   var getString = loc.split('?')[1];
   var GET = getString.split('&');
   var get = {};//this object will be filled with the key-value pairs and returned.

   for(var i = 0, l = GET.length; i < l; i++){
      var tmp = GET[i].split('=');
      get[tmp[0]] = unescape(decodeURI(tmp[1]));
   }
   return get;
}


var Consultants = getGET()["Consultants"];

var Search = getGET()["Search"];

var latitud = getGET()["latitud"];

var longitud = getGET()["longitud"];

var sector = getGET()["sector"];

var Cliente = Search

if (Search != ""){
    clienturl = Search
    clienturl = unescape(clienturl);
}else{
    clienturl = "";
}



(function($){



$(document).ready(function() {
    var editor = new $.fn.dataTable.Editor( {
        pageLength: 10,
        lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
        serverside: true,
        ajax: '../table_bbdd/table_Clients/php/table.php?sector='+sector+'&Consultants='+Consultants+'',
        table: '#clients',
        fields: [

    

            {
                "label": "User:",
                "name": "Clients.IdUsers",
                "type":   "hidden"
                                                
            },


            {
                "label": "Sector:",
                "name": "Clients.idSector",
                "type":   "select",
                def: sector
                            
                
            },                      

            {
                "label": "DOWCode:",
                "name": "Clients.DOWCode",
                //"type":   "datetime"
            },

            {
                "label": "OrderCode:",
                "name": "Clients.OrderCode"
                
            },
            {
                "label": "Client:",
                "name": "Clients.Client"
                
            },

            {
                "label": "VATNumber:",
                "name": "Clients.VATNumber"
                
            },
            {
                "label": "Address:",
                "name": "Clients.Address"
                
            },
            {
                "label": "ZIP:",
                "name": "Clients.ZIP"
                
            },

            {
                "label": "City:",
                "name": "Clients.City"
                
            },

            {
                "label": "Phone:",
                "name": "Clients.Phone",

            },

            {
                "label": "Contact:",
                "name": "Clients.Contact"
                
            },
            {
                "label": "Website:",
                "name": "Clients.Website"
                
            },

            {
                "label": "Email:",
                "name": "Clients.Email"
                
            },
            {
                "label": "Closing Day 1:",
                "name": "Clients.IdClosingDay1",
                "type":   "select",
                 
                
            },
            {
                "label": "Closing Day 2:",
                "name": "Clients.IdClosingDay2",
                "type":   "select",
                    
                
            },

            {
                "label": "Photo:",
                "name": "Clients.Photo_Client",
                type: "upload"
                
            },


            {
                "label": "Opening Hours:",
                "name": "Clients.Close"
                
            },

            {
                "label": "Desc:",
                "name": "Clients.Desc"
                
            },
                                

        ],


    } );

    var table = $('#clients').DataTable( {
        pageLength: 5,
        lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
        serverside: true,
        dom: 'Bfrtip',
        ajax: {
            url: "../table_bbdd/table_Clients/php/table.php?sector="+sector+"&Consultants="+Consultants+"",
            type: "POST"
        },
        serverSide: true,
        procesing: true,
        columns: [


            {
                "data": "Clients.Id"
            },                  
    
            {
                "data": "Clients.Client"
            },


            {
                "data": "Clients.City"
            },

            {
                "data": "Clients.Phone"
            },

            {
                "data": "Clients.Contact"
            },      

            {
                "data": "Clients.Email"
            },

            {
                "data": "Img_Clients.Photo"
            },

        ],
    columnDefs: [ {
    "targets": 0,
    "data": "download_link",
    "render": function ( data, type, full, meta ) {


      return '<a id="geo" class="enlaceajax btn mt-ladda-btn ladda-button btn-outline" href=view_p_list.php?id='+data+'&Consultants='+Consultants+'&latitud='+latitud+'&longitud='+longitud+'&sector='+sector+'><img style="width: 25px; height: auto;" src="../img/encuesta.png"></a><a id="geo" class="enlaceajax btn blue mt-ladda-btn ladda-button btn-outline" href=view_visits.php?id='+data+'&Consultants='+Consultants+'&latitud='+latitud+'&longitud='+longitud+'&sector='+sector+'>Visits</a><a class="enlaceajax btn yellow mt-ladda-btn ladda-button btn-outline" href=view_EndUsers.php?id='+data+'&refresh=3&Consultants='+Consultants+'&latitud='+latitud+'&longitud='+longitud+'&sector='+sector+'>EndUsers</a><a class="enlaceajax btn red mt-ladda-btn ladda-button btn-outline" href=view_Orders.php?id='+data+'&Consultants='+Consultants+'&latitud='+latitud+'&longitud='+longitud+'&sector='+sector+'>Orders</a>';



    }


  },

{
    "targets": 6,
    "data": "download_link",
    "render": function ( data, type, full, meta ) {

        if (data == 'null'){
      
      return data;
  }else{

    return '<a href="../img_client/'+data+'"><img style="width: 50px; height: auto;" src="../img_client/'+data+'"></a>';
  }



    }


  }


   ],


        oSearch: {"sSearch": ""+clienturl+""},
        select: true,
        buttons: [
            { extend: 'create', editor: editor },
            { extend: 'edit',   editor: editor },
            { extend: 'remove', editor: editor },
            {
                    extend: 'print',
                    text: 'Print',
                    columns: ':visible',
                    autoPrint: true,
                    orientation: 'landscape',
                    pageSize: 'A4',
                 },
                    'copyHtml5',
                    'excelHtml5',
                    'csvHtml5',
                    'pdfHtml5',
                    'pageLength'
        ]
    } );



} );

}(jQuery));

/////////////////////////////////////////////////////////////////

you can see the error:

AFTER ERROR: (1.JPG)

BEFORE ERROR: (2.JPG)

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

1.JPG 40.1K
2.JPG 89.1K

Replies

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin

    I'm guessing that some of the dependencies, such as JSZip for the Excel export, haven't been loaded. If you give me a link tot he page I'd be happy to take a look and help debug it.

    Allan

  • monsalvezmonsalvez Posts: 2Questions: 0Answers: 0
    edited October 2016

    Great!!!!
    Give me a mail to send the URL, user and password

    TY ALLAN!!

    You can write to jdominguez@monsalvez.com

    subject: Dont work buttons Export....

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin

    If you could just ping me a PM with the details, that would be great. Click my name above and then the "Send message" button.

    Allan

This discussion has been closed.