row.child no funciona

row.child no funciona

silenssilens Posts: 101Questions: 40Answers: 0

Buenas, Estoy intentando mostrar el row.child en esta tabla pero no me funciona. Alguien me puede ayudar? Un saludo y gracias


function pry_1_his_n(pry){ var parametros = { "pry":pry, }; $.ajax ({ async:false, data: parametros, "url": "php/_n.php", type: "POST", success: function(data){ objJson=JSON.parse(data); } }); var tblHistoriaP='<div class="table-responsive">'+ '<table id="tblHistoriaP" cellspacing="0" width="100%">'+ '<thead>'+ '<tr>'+ '<td>'+'&nbsp;&nbsp;' +' '+ '</td>' + '<td>Id:</td>'+ '<td>Nombre</td>'+ '<td>Descripción</td>'+ '<td>Presupuesto</td>'+ '</tr>' +'</thead>'+'<tbody>'; for(var i = 0; i < objJson.length; i++){ tblHistoriaP += '<tr style="cursor: pointer;">'+ '<td>'+ '&nbsp;&nbsp;'+'<img src="img/flecha.png" id="idTareaT" title="Clic para ver '+ objJson[i].name +' " width="15" height="15"/> '+ '</th>' + '<td>'+objJson[i].id+'</td>'+ '<td>'+objJson[i].name+'</td>'+ '<td>'+objJson[i].dsc+'</td>'+'<td>'+objJson[i].prsp_def+'</td>'+ '</tr>'; } tblHistoriaP += '</tbody>'+'</table>'+'</div>'; var table = $('#tblHistoriaP').DataTable(); $('#tblHistoriaP tbody').on('click', 'td.details-control', function () { var tr = $(this).parents('tr'); var row = table.row( tr ); if ( row.child.isShown() ) { row.child.hide(); tr.removeClass('shown'); } else { row.child( "hola" ).show(); tr.addClass('shown'); } } );

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin
    Answer ✓

    Happy to take a look at a test case showing the issue.

    Thanks,
    Allan

  • silenssilens Posts: 101Questions: 40Answers: 0

    Buenas, lo unico que tennia que hacer es crear la tabla como objeto datatable de esta manera

    $(document).ready(function() {
        variable ajemplo=$('#tablaejemplo').DataTable({
            
        });
     });
    
This discussion has been closed.