基本上,代码运行良好,只是当数据越来越大时,加载速度变得非常慢。
任何人都可以建议如何提高装货速度?
下面是我的代码:
Javascript
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0]
}]
});
});
</script>数据表:
<table class="list" id="example">
<thead>
<tr>
<td class="first" width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></td>
<td class="left">Location ID</td>
<td class="left">Location</td>
<td class="left">Issued By</td>
<td class="left">Supervise by Role</td>
<td class="right">Action</td>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM location";
$query = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($query) > 0) {
while ($data = mysql_fetch_assoc($query)) {
?>
<tr>
<td style="text-align: center;"><input type="checkbox" name="selected[]" value="<?php echo $data['locationname']; ?>">
</td>
<td class="left"><?php echo $data['lid']; ?></td>
<td class="left"><?php echo $data['locationname']; ?></td>
<td class="left"><?php echo $data['issuedby']; ?></td>
<td class="left"><?php echo "Supervisor - " . $data['locationname']; ?></td>
<td class="right"> [ <a href="index.php?cmd=location&route=location&fn=view&lid=<?php echo $data['lid']; ?>">View</a> ] [ <a href="index.php?cmd=location&route=location&fn=edit&lid=<?php echo $data['lid']; ?>">Edit</a> ]</td>
</tr>
<?php
}
}
?>
</tbody>
</table>发布于 2014-08-06 06:48:46
如果数据集很大,则应该使用AJAX以块形式加载数据。
下面是可以从其中获取有关向datatable添加新行的信息的链接:
row.html
如示例中所示,datatable将处理分页和排序本身。
https://stackoverflow.com/questions/25153760
复制相似问题