问题
i want to hide datatable thead if table dont have any data.
oTable_topics =$('#showTopics').dataTable({
"bLengthChange": false,
"bStateSave": true,
"iDisplayLength": 12,
"bScrollCollapse": true,
"bJQueryUI": true,
"bAutoWidth": false,
"sAjaxSource": "server_processing.php",
"sPaginationType": "full_numbers",
"bProcessing": true
});
function clickRowHandler_topics() {
$('#showTopics tbody tr').bind('click', function () {
var aData = oTable_topics.fnGetData( this );
iId_topics = aData[1];
});
}
i think if table dont have any data hiding thead is good for display any message for users, how to hide that?
回答1:
Try this:
"fnDrawCallback": function ( oSettings ) {
$(oSettings.nTHead).hide();
}
"fnDrawCallback" function is called on every 'draw' event, and allows you to dynamically modify any aspect you want about the created DOM.
回答2:
Try to add in this option:
"sDom": 'rt'
it will hide header and footer, but first,you still need to check whether there is return data or not.
来源:https://stackoverflow.com/questions/16802753/jquery-datatables-hide-thead