Dynamic header and table data
Dynamic header and table data
dthemes
Posts: 11Questions: 6Answers: 0
Hi,
I'm using json to dynamically set data and header. I did it like below :
$.getJSON("http://127.0.0.1/data/info", function( data ) {
$(document).ready(function() {
$('#log').html( '<table class="display compact" id="log-data" width="100%"></table>' );
var table = $('#log-data').dataTable( {
"dom": '<"tblContainerT"T><"tblContainerTop"lf><rt><"bottom"ip>',
"tableTools": {
"sSwfPath": "/swf/copy_csv_xls_pdf.swf"
},
"data": data['tbody'],
"columns": data['thead'],
"lengthMenu":[[25,200,500,-1],[25,200,500,"All"]],
'fnInitComplete' : function () {
$("thead tr").clone().appendTo($("tfoot tr")) ;
}
});
});
});
It works fine. However, I noticed footer is not generated and apparently this is because header is generated dynamically (I read it somewhere). So I tried to use 'fnInitComplete' and clone the header columns to the footer. I did it like below :
'fnInitComplete' : function () {
$("thead tr").clone().appendTo($("tfoot tr")) ;
}
Well, it seems its not working and unfortunately it is bit difficult for me to understand what's wrong. Could you point me to the right direction ?
Thanks,
This discussion has been closed.