我正在使用數據表管道來生成表。我的表有動態列意味著它沒有固定列。欄目列數隨月份的變化而變化。假設當月該表有 4 列,但 11 月份有 32 列。當我將月份更改為十一月時,它給了我Cannot read property 'style' of undefined這個錯誤。我的數據表初始化函數: function monthlyAttendanceStatusDatatableInit(tableIdOrCss, url, columns, sortArr, pageLength, year, month) { console.log(columns); var param = { "responsive": false, // "columnDefs": [ // {responsivePriority: 1, targets: -1}, // {responsivePriority: 2, targets: 0} // ], "aLengthMenu": [[10, 20, 50, -1], [10, 20, 50, 'All']], "pageLength": pageLength || 10, "iDisplayLength": pageLength || 10, //"language": { search: "" }, "sPaginationType": "simple_numbers", // you can also give here 'simple','simple_numbers','full','full_numbers' "oLanguage": { "sSearch": "Search:", "sProcessing": "Loading..." }, "ajax": $.fn.dataTable.pipeline( { url: url, data: { 'month': month, 'year': year }, pages: 2 // number of pages to cache }), "processing": true, "serverSide": true, "searching": true, // "bPaginate": true, // "fnDrawCallback":function(){ // if(typeof callBack == 'function'){ // callBack(); // } // }, "destroy": true, "paging": true, "retrieve": false, "aoColumns": columns, "aaSorting": sortArr, //[[ 0, "asc" ],[ 1, "desc" ]] // Sort by first column descending // "scrollX": true, // "createdRow": function( row, data, dataIndex ) { // $(row).attr('id', 'employee-'+data.id); // } }; // $(tableIdOrCss).remove(); var table = $(tableIdOrCss).DataTable(param); return table; }
未捕獲的類型錯誤:無法使用數據表管道讀取未定義的屬性“樣式”
慕田峪4524236
2023-09-28 16:04:11