我想问一些关于bootstrap数据表的问题,我的数据库mysql中有超过3000个数据。数据表运行良好,但问题是何时从db加载所有数据。我在chrome开发人员工具中看到它,加载所有数据16秒的时间。我怎么能得到一些技巧或建议来解决它很快加载所有数据.. ??
这是我在html中的代码
<div class="table table-responsive">
<table class="table table-striped table-responsive table-bordered table-hover" id="karyawan">
<thead>
<tr>
<th style="text-align:center;">Action</th>
<th width="5px">No</th>
<th style="text-align:center;">id</th>
<th style="text-align:center;">KD Klas</th>
<th style="text-align:center;">Nip Lama</th>
<th style="text-align:center;">KD Tarif</th>
<th style="text-align:center;">KD Unit</th>
<th style="text-align:center;">No KTP</th>
<th style="text-align:center;">NIP Terbaru</th>
<th style="text-align:center;">Nama Pegawai</th>
<th style="text-align:center;">Alamat</th>
<th style="text-align:center;">Tanggal Lahir</th>
<th style="text-align:center;">Tempat Lahir</th>
<th style="text-align:center;">Agama</th>
<th style="text-align:center;">Kelamin</th>
<th style="text-align:center;">Status Nikah</th>
<th style="text-align:center;">Departemen</th>
<th style="text-align:center;">Jabatan</th>
<th style="text-align:center;">Nama Unit</th>
<th style="text-align:center;">Bagian</th>
<th style="text-align:center;">Jenis Gaji</th>
<th style="text-align:center;">Tahun Masuk</th>
<th style="text-align:center;">Tahun Keluar</th>
<th style="text-align:center;">Status</th>
<th style="text-align:center;">Rekening</th>
<th style="text-align:center;">Upah Bulan</th>
<th style="text-align:center;">Upah Hari</th>
<th style="text-align:center;">Lembur Per Jam</th>
<th style="text-align:center;">Kode Kelompok</th>
<th style="text-align:center;">Tunjangan</th>
<th style="text-align:center;">JHT</th>
<th style="text-align:center;">BPJS</th>
<th style="text-align:center;">Shift</th>
<th style="text-align:center;">Tunshift</th>
</tr>
</thead>
<tbody>
<?php
include_once("../../../../koneksi/conn.php");
$sql = "SELECT * FROM pegawai order by idpeg DESC";
$query = $koneksi->query($sql);
$no=1;
while($row = $query->fetch_array()){
echo"<tr>";
echo"<td><button type='button' class='btn btn-primary' id='btnPopupEditKar' data-toggle='modal' data - target='#modalupdatekar' onClick='clickShowKar(this)' title='edit'><span class='glyphicon glyphicon-edit'></span></button> <button type='button' class='btn btn-primary' id='delete' title='delete' onClick='confirmDeleteKar(this)'><span class='glyphicon glyphicon-trash'></span></button></td>";
echo"<td>$no</td>";
echo"<td id='IDPEG'>$row[0]</td>";
echo"<td id='KDKLASS'>$row[1]</td>";
echo"<td id='NIPLAMA'>$row[2]</td>";
echo"<td id='KDTAR'>$row[3]</td>";
echo"<td id='KODEUNIT'>$row[30]</td>";
echo"<td id='KTP'>$row[4]</td>";
echo"<td id='NIP'>$row[5]</td>";
echo"<td id='NAMA'>$row[6]</td>";
echo"<td id='ALAMAT'>$row[7]</td>";
echo"<td id='LAHIR'>$row[8]</td>";
echo"<td id='TEMPAT'>$row[9]</td>";
echo"<td id='AGAMA'>$row[10]</td>";
echo"<td id='KELAMIN'>$row[11]</td>";
echo"<td id='NIKAH'>$row[12]</td>";
echo"<td id='DEP'>$row[13]</td>";
echo"<td id='JAB'>$row[15]</td>";
echo"<td id='BAG'>$row[14]</td>";
echo"<td id='NAMAUNIT'>$row[31]</td>";
echo"<td id='JENGAJI'>$row[16]</td>";
echo"<td id='TASUK'>$row[17]</td>";
echo"<td id='TALUAR'>$row[18]</td>";
echo"<td id='STATUS'>$row[19]</td>";
echo"<td id='NOREK'>$row[20]</td>";
echo"<td id='UBUL'>$row[21]</td>";
echo"<td id='UHAR'>$row[22]</td>";
echo"<td id='LEMJAM'>$row[23]</td>";
echo"<td id='KODEKEL'>$row[24]</td>";
echo"<td id='TUNJANGAN'>$row[25]</td>";
echo"<td id='JHT'>$row[26]</td>";
echo"<td id='BPJS'>$row[27]</td>";
echo"<td id='SHIFT'>$row[28]</td>";
echo"<td id='TUNSHIFT'>$row[29]</td>";
echo "</tr>";
$no++;
}
?>
</tbody>
</table>
</div>
这是我的js
$(document).ready(function(){
$("#karyawan").dataTable({
"lengthMenu": [[5, 10, -1], [5, 10,"All"]],
"iDisplayLength": 5
});
});
谢谢你,
最好的问候