jQuery datatables hide thead

自古美人都是妖i 提交于 2019-12-12 13:17:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!