【发布时间】:2015-10-12 06:47:15
【问题描述】:
我在 JSP 文件中创建了表,它显示所有记录而没有过滤和“显示 10 个条目”计数。我的代码如下所示。
当我搜索其他答案时,解决方案是设置iDisplayLength。但这对我不起作用。
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="https://cdn.datatables.net/plug-ins/9dcbecd42ad/integration/jqueryui/dataTables.jqueryui.css">
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">
function searchfiles() {
$('#fileLoader').DataTable({
"bProcesing" : true,
"bServerSide" : true,
"iDisplayLength" : 10,
destroy: true, //reinitializing of the data table
"aoColumns" : [ {
"sTitle" : "Rate Files",
"mData" : "filePath",
} ],
"columnDefs": [ {
"targets": 0,
"data": "download_link",
"render": function ( data, type, full, meta ) {
return '<a href="'+data+'">'+data.split('.pdf')[0]+'</a>';
}
} ],
"fnServerData" : function(sSource, aoData, fnCallback) {
aoData.push({
"name" : "hotel",
"value" : $("#hotel").val()
});
aoData.push({
"name" : "season",
"value" : $("#season").val()
});
aoData.push({
"name" : "market",
"value" : $("#market").val()
});
aoData.push({
"name" : "sheetDate",
"value" : $("#sheet_date").val()
});
$.ajax({
"type" : "POST",
"url" : "searchfiles",
"data" : aoData,
"success" : fnCallback
});
},
});
}
</script>
<table id="fileLoader" width="100%">
<thead>
<tr>
<th>Rate Files</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
【问题讨论】:
标签: ajax jsp datatables