datatables recover value not shown in table

Asked

Viewed 318 times

1

I have a table generated by datatables that shows name, document and phone. It works perfectly more I want to appear tooltip to show additional information, i even managed to show by taking the value inserted in tr plus the problem and that the additional information will not appear and I need help for this because my knowledge of the library is limited, follows below the code:

table:

                  <table id="tabelaclientes" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>Nome</th>
                    <th>Documento</th>
                    <th>Telefone</th>
                    <th></th>
                  </tr>
                </thead>
              </table>

jquery:

    $(document).ready(function() {
/*
 * First step is to create title attributes for the rows in the table
 * This isn't needed if the required 'title' attribute is already set in the HTML in the
 * DOM 
 */


/* Init DataTables */
var oTable = $('#tabelaclientes').DataTable({
        "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "Todos"] ],
        "processing": true,
        "serverSide": true,
        "oLanguage": {
            "sUrl": "busca/pt-br.txt"
        },

        "ajax": "busca/clientes.php",

        "fnDrawCallback": function( settings ) {
     $('#tabelaclientes tbody tr').each( function() {
    var sTitle;
    var nTds = $('td', this);
    var nome = $(nTds[0]).text(); 
    var documento = $(nTds[1]).text();
    var telefone = $(nTds[2]).text();
    var ie = $(nTds[4]).text();
    var endereco = $(nTds[5]).text();
    var bairro = $(nTds[6]).text();
    var uf = $(nTds[7]).text();
    var cidade = $(nTds[8]).text();
    var email = $(nTds[9]).text();
        sTitle =  'Nome da Empresa: ' +nome+ '\nCPF/CNPF: ' +documento+ '\nIE: ' +ie+ '\nEndereço: ' +endereco+ '\nBairro: ' +bairro+ '\nUF: ' +uf+ '\nCidade: ' +cidade+ '\nTelefone: ' +telefone+ '\nEmail: ' +email;


    this.setAttribute( 'title', sTitle );
} );
}

    });

/* Apply the tooltips */
oTable.$('tr').tooltip( {
    "delay": 0,
    "track": true,
    "fade": 250
} );

} );

I receive the data like this:

{"draw":1,"recordsTotal":821,"recordsFiltered":821,"data":[["3 MARC IMPRESSOS GRAFICOS LTDA ME","02651657000144"
,null,"<a class='editar fancybox.iframe' href='cadastro_editar.php?id=574'><img src='imagens\/editar
.png' width='24px' height='24px' border=0  title='Editar acesso'\/><\/a><a class='permissao fancybox
.iframe' href='usuario_permissao.php?id=574'><img src='imagens\/recurso.png' width='24px' height='24px'
 border=0  title='Editar ficha pessoal'\/><\/a>",null,"R JOAO PINHEIRO, 613",null,"RJ",null,null]]}

1 answer

0


After much searching I found a solution to this issue and I return here to share so that if someone else goes through this problem can solve.

replace this:

var endereco = $(nTds[5]).text();

therefore:

var endereco = oTable.row(this).data()[5]; 

as the value was hidden in the table I could not pick up the same way by selecting the td.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.