DataTables warning: table id=tHasilCarian - Requested unknown parameter '1' for row 0
DataTables warning: table id=tHasilCarian - Requested unknown parameter '1' for row 0
heeroes
Posts: 2Questions: 1Answers: 0
i got this warning message when i try to generate my print datatable. this happen when i tried to add index column for print datatable. I try added this code t.cell(cell).invalidate('dom');
and got a warning message. here is my code
var t = $('#tHasilCarian').DataTable( {
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,"scrollX": true,
"autoWidth": false,
dom: 'Bfrtip',
buttons: [
{
extend: 'print',
text: '<i class="fa fa-print"></i> Cetak',
customize: function ( win ) {
$(win.document.body).find('h1')
.replaceWith('Senarai Dokumen pada <?php echo date('d-m-Y') ?>');
$(win.document.body).find('table')
.css('font-size','xx-small')
},
autoPrint: true
}
],
"columnDefs": [ {
"searchable": false,
"orderable": false,
"targets": 0
} ],
"order": [[ 1, 'asc' ]]
});
t.on( 'order.dt search.dt', function () {
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
t.cell(cell).invalidate('dom');
} );
} ).draw();
table with data
<table id="tHasilCarian" class="table table-bordered table-hover table-responsive">
<thead>
<tr>
<th></th>
<th>Fail</th>
<th>No Rujukan / Perkara</th>
<th>Bil dlm fail</th>
<th>Nama Penghantar</th>
<th>Jabatan Penghantar</th>
<th>Jenis</th>
<th>Pegawai Diarahkan</th>
</tr>
</thead>
<tbody>
<tr>
<td width="20px"></td>
<td width="200px">TEST NO FAIL : TEST TAJUK</td>
<td width="300px">JKN.PHG IT(S)/23/566 - PERLANTIKAN </td>
<td>356</td>
<td>ADIB MOHD YUSOF</td>
<td>HOSPITAL TENGKU AMPUAN AFZAN</td>
<td>SURAT</td>
<td width="400px">NOOR SYAFINI BT NOOR ADZMY, MOHD FAKRI BIN RAKIB, ABU BAKAR BIN ALI, DR RAHIMAH BT IBRAHIM, MAZELAH BINTI OMAR, HASSAN BIN ABDUL SAMAD, MOHD NAZRI B AWANG, ROSMIZU BIN ISMAIL, DR USAMAH BIN ISMAIL, DR IDILIA BINTI ISHAHAR</td>
</tr>
<tr>
<td width="20px"></td>
<td width="200px">TEST NO FAIL : TEST TAJUK</td>
<td width="300px">JKN.PHG IT(S)/23/566 - PERLANTIKAN </td>
<td>356</td>
<td>ADIB MOHD YUSOF</td>
<td>BAHAGIAN PENGURUSAN</td>
<td>SURAT</td>
<td width="400px"></td>
</tr>
<tr>
<td width="20px"></td>
<td width="200px">TEST NO FAIL : TEST TAJUK</td>
<td width="300px">JKN.PHG IT(S)/23/566 - KEPUTUSAN TENDER BAGI TAWWARAN TENDER PERKHIDMATAN KAWALAN KESELAMATAN TANPA SENJATA DI HOSPITAL BENTONG PAHANG DALAM TEMPOH DUA (2) TAHUN</td>
<td>222</td>
<td></td>
<td>BAHAGIAN PENGURUSAN</td>
<td>FAKS</td>
<td width="400px"></td>
</tr>
<tr>
<td width="20px"></td>
<td width="200px">TEST NO FAIL : TEST TAJUK</td>
<td width="300px">SSS - PERLANTIKAN AHLI JAWATANKUASA PEMBUKA TENDER BAGI TAWWARAN TENDER PERKHIDMATAN KAWALAN KESELAMATAN TANPA SENJATA DI HOSPITAL BENTONG PAHANG DALAM TEMPOH DUA (2) TAHUN</td>
<td>1</td>
<td></td>
<td>BAHAGIAN PERGIGIAN</td>
<td>BORANG</td>
<td width="400px"></td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<th>Fail</th>
<th>No Rujukan / Perkara</th>
<th>Bil dlm fail</th>
<th>Nama Penghantar</th>
<th>Jabatan Penghantar</th>
<th>Jenis</th>
<th>Pegawai Diarahkan</th>
</tr>
</tfoot>
</table>
Any Ideas?
This discussion has been closed.
Answers
your .each parameters are reverse. Index I first object in the array second.
thank you for replying my post, can you show me how to fix it?
Here is my working sample that adds an index column
http://live.datatables.net/heyudefe/1/edit