第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

未捕獲的類型錯(cuò)誤:無法使用數(shù)據(jù)表管道讀取未定義的屬性“樣式”

未捕獲的類型錯(cuò)誤:無法使用數(shù)據(jù)表管道讀取未定義的屬性“樣式”

慕田峪4524236 2023-09-28 16:04:11
我正在使用數(shù)據(jù)表管道來生成表。我的表有動(dòng)態(tài)列意味著它沒有固定列。欄目列數(shù)隨月份的變化而變化。假設(shè)當(dāng)月該表有 4 列,但 11 月份有 32 列。當(dāng)我將月份更改為十一月時(shí),它給了我Cannot read property 'style' of undefined這個(gè)錯(cuò)誤。我的數(shù)據(jù)表初始化函數(shù):   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;        }
查看完整描述

1 回答

?
千萬里不及你

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊

正如您在 DataTable 文檔中關(guān)于destroy()方法所看到的,在列更改的情況下,您應(yīng)該在添加jQuery#empty()新列之前銷毀數(shù)據(jù)表實(shí)例并通過調(diào)用刪除表元素的所有子節(jié)點(diǎn)。

var table = $('#myTable').DataTable();

?

$('#submit').on( 'click', function () {

? ? $.getJSON( 'newTable', null, function ( json ) {

? ? ? ? table.destroy();

? ? ? ? $('#myTable').empty(); // empty in case the columns change

?

? ? ? ? table = $('#myTable').DataTable( {

? ? ? ? ? ? columns: json.columns,

? ? ? ? ? ? data:? ? json.rows

? ? ? ? } );

? ? } );

} );

這是工作示例



查看完整回答
反對(duì) 回復(fù) 2023-09-28
  • 1 回答
  • 0 關(guān)注
  • 122 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)