Datatables, jquery, title not showing

Datatables, jquery, title not showing

本文关键字:showing not jquery Datatables title      更新时间:2024-03-11

下面是我的数据表的标题行,加载时它不会显示任何内容。。。。我做错了什么?

title: function () {
    var today = new Date();
    return 'Headcount Per Week - Week ' + myWeekCalc(today) + ',<?php echo $start;?> to <?php echo $finish;?>';
},
function myWeekCalc(date) {
    var checkDate = new Date(date.getTime());
    // Find
    checkDate.setDate(checkDate.getDate() + 185 - (checkDate.getDay()));
    var time = checkDate.getTime();
    checkDate.setMonth(0); // Compare with Jan 1
    checkDate.setDate(1);
    return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
}

标题应该是字符串,而不是函数。试着立即执行你的标题功能,就像这样,

title: (function () {
    function myWeekCalc(date) {
        var checkDate = new Date(date.getTime());
        // Find
        checkDate.setDate(checkDate.getDate() + 185 - (checkDate.getDay()));
        var time = checkDate.getTime();
        checkDate.setMonth(0); // Compare with Jan 1
        checkDate.setDate(1);
        return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
    }
    var today = new Date();
   return 'Headcount Per Week - Week ' + myWeekCalc(today) + ',<?php echo $start;?> to <?php echo $finish;?>';
}())