2

我即将结束我的人口普查数据库表 Web 应用程序,还有一个问题。我一直在试图弄清楚在较大的数据表之后加载较小的数据表时如何清除多余的列标题。例如,我有以下功能:

function nationalAgeGender() {
    (function($) {
        $('#data-entry').dataTable({
            "bProcessing": true,
            "bScrollInfinite": true,
            "bScrollCollapse": true ,
            "bAutoWidth": false,
            "bDestroy": true,   
            "iDisplayLength": -1,   
            "sDom": '<"top">rt<"bottom">',
            "aaSorting": [[8,'asc']],
            "sAjaxSource": "/CensusDatabase/database_scripts/NationalAgeGender.php",
            "aoColumns": [
                { "sTitle": "Age group" },
                { "sTitle": "Total population (both genders)" },
                { "sTitle": "Male population" },
                { "sTitle": "Female population" },
                { "sTitle": "% (both genders)" },
                { "sTitle": "Male %" },
                { "sTitle": "Female %" },
                { "sTitle": "Males per 100 females" },
                { "bVisible": false }
            ]
        });
    })(jQuery);
}

function combinedAgeGender() {
    (function($) {
        $('#data-entry').dataTable({
           "bProcessing": true,
           "bScrollInfinite": true,
           "bScrollCollapse": true ,
           "bAutoWidth": false, 
           "iDisplayLength": -1,
           "bDestroy": true,
           "sDom": '<"top">rt<"bottom">',
           "aaSorting": [[8,'asc']],
           "sAjaxSource": "/CensusDatabase/database_scripts/CombinedAgeGender.php",
           "aoColumns": [
               { "sTitle": "Age group" },
               { "sTitle": "National total population (both genders)" },
               { "sTitle": "National male population" },
               { "sTitle": "National female population" },
               { "sTitle": "National % (both genders)" },
               { "sTitle": "National male %" },
               { "sTitle": "National female %" },
               { "sTitle": "National males per 100 females" },
               { "bVisible": false }, 
               { "bVisible": false }, 
               { "sTitle": "Arizona total population (both genders)" },
               { "sTitle": "Arizona male population" },
               { "sTitle": "Arizona female population" },
               { "sTitle": "Arizona % (both genders)" },
               { "sTitle": "Arizona male %" },
               { "sTitle": "Arizona female %" },
               { "sTitle": "Arizona males per 100 females" }

           ]
       });
   })(jQuery);
}

如果我先加载第二个函数然后加载第一个函数,我会得到以下结果: 多余的列

我尝试将此代码添加到我的第一个函数中:

"fnDrawCallback": function () {
    $('#data-entry thead').html('');            
}

但是,它会清除所有列,而不仅仅是多余的列。

有人可以帮我吗?

4

0 回答 0