Datatable with laravel

0

I am using datatables to show the information of my clients and some other useful fields, the datatable works perfectly, but now I need to create reports according to the query made with the searchable datatable.

through the method getElementsByTagName ('tr') .. I get the information of each value of the query column, but this method returns it to me as an html collection ... I need to be able to send that collection to the controller and it does not work, it does not recognize the information ... there is some way to do this what I have tried so far has not worked ... I am using laravel. I enclose the code thank you in advance ...

 $("#omg").click(function() {
    var info = document.getElementsByTagName('td');
    var route= 'pdf/'+info+'/';
    alert(info[0].innerHTML );
    $.ajax({
            url: route,
            dataType: "JSON",
            success: function(result)
            {
               console.log('done');
            },
            fail: function(){
               console.log('fracaso');
            }
        });    
});

$('#logs').DataTable({
    "processing": true,
    //"serverSide": true,
    "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
    "language": {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
                  },
});

the #omg is a one-button id with which reports are generated

    
asked by Camilo 06.07.2018 в 06:58
source

1 answer

0

I understand that when executing getElementsByTagName I would only collect the information from the visible td and I would omit the hidden ones that may be from the dataTable paging, in case there are many records, I think one of your options could be to use the GetData method which would return all the information of the table in an arrangement.

$("#table").dataTable().fnGetData()

I attached the method link of the api dataTable please note the "d" lowercase, since there are other methods with "D" capitalized please do not confuse. link

    
answered by 06.07.2018 / 17:04
source