I am looking for a way to show a child.rows
but the only way that can be shown is with a return
direct.
then I made this code so that outside of ajax I take those values but it does not give me, I hope you can help me.
CODE
function format (data) {
$.ajax({
url: "list_data",
type: 'POST',
data: {'data':data[0]},
success: function (result){
for (var i = result.length - 1; i >= 0; i--){
var resultado = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Full name:result[i].nombre</td>'+
'<td></td>'+
'</tr>'+
'</table>';
}
return resultado;
}
});
}
return result; this is what I think is wrong, and as you see I need to return that code inside the for and if I do the return inside the for does not work it has to be outside the ajax method
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );