- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试使用服务器端处理在 php 项目上实现 jquery datatables,但分页不起作用,而且我在 firebug 控制台中没有任何错误。
页面简洁明了,html代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jq-2.2.3/dt-1.10.12/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/jq-2.2.3/dt-1.10.12/datatables.min.js"></script>
</head>
<body>
<table class="table">
<thead>
<tr>
<th col-data="item_id">Item Id</th>
<th col-data="name">Name</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(document).ready(function() {
var dataTable = $('.table').DataTable( {
"processing": true,
"serverSide": true,
"buttons": [],
"order": [],
"ajax":{
url :"{{ url('stock_acc_get') }}", // json datasource
type: "post",
}
} );
} );
</script>
</body>
</html>
这是服务器上发布的数据(在 firebug 控制台中查看):
columns[0][data] 0
columns[0][name]
columns[0][orderable] true
columns[0][search][regex] false
columns[0][search][value]
columns[0][searchable] true
columns[1][data] 1
columns[1][name]
columns[1][orderable] true
columns[1][search][regex] false
columns[1][search][value]
columns[1][searchable] true
draw 1
length 10
search[regex] false
search[value]
start 0
这是来自服务器的 json 响应:
{
"draw":1,
"recordsTotal":23,
"recordsFiltered":10,
"data": [
["100018","Test Acc"],["100019","Test Acc 2"],
["100020","Test Acc 3"],["5845645","Optional 1"],
["56456456","Optional 2"],["541515","Optional 3"],
["845812","Optional 4"],["103646","Belte Setesdal"],
["103647","Belte Setesdal"],["103681","Belte Sigdal-Eggedal"]
]
}
页面设置显示10条记录。记录总数为 23,它不会创建导航到下一页的链接。我附上了一张照片以便更好地理解,下一页/上一页按钮被禁用,它显示只有一页。
最佳答案
recordsFiltered
应该表示通过搜索框(以及任何其他)过滤器的记录数,而不是页面上的记录数。
您告诉 DataTables 只有 10 条相关记录,因此它不会尝试为其他 13 条设置分页。
查看第三个DataTables FAQ post (在服务器端处理类别中),或 Server-side processing该帖子中链接的页面以获取更多信息。
关于javascript - jquery 数据表服务器端分页不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38212906/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!