欢迎光临

木子屋

标题: Bootstrap Table服务器端分页使用示例

作者: dnawo

日期: 2019-11-22 10:53 PM

分类: Web编程

内容: Bootstrap Table服务器端分页主要通过设置data-pagination和data-side-pagination两个属性来实现：
复制内容到剪贴板 程序代码<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap Table服务器端分页使用示例</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--引入Bootstrap Table及关联样式-->
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.6.3/css/all.css">
<link rel="stylesheet" href="//unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.css">
</head>
<body>
<!--内容-->
<table data-toggle="table" data-url="data_json.asp" data-pagination="true" data-side-pagination="server">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
<!--引入Bootstrap Table及关联脚本-->
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="//unpkg.com/bootstrap-table@1.15.3/dist/bootstrap-table.min.js"></script>
<script src="//unpkg.com/bootstrap-table@1.15.3/dist/locale/bootstrap-table-zh-CN.min.js"></script>
</body>
</html>
data_json.asp返回格式：
复制内容到剪贴板 程序代码{"total": 50,"rows":[{"id": "1","name": "Item 1","price": "$1"},{"id": "2","name": "Item 2","price": "$2"},{"id": "3","name": "Item 3","price": "$3"},{"id": "4","name": "Item 4","price": "$4"},{"id": "5","name": "Item 5","price": "$5"},{"id": "6","name": "Item 6","price": "$6"},{"id": "7","name": "Item 7","price": "$7"},{"id": "8","name": "Item 8","price": "$8"},{"id": "9","name": "Item 9","price": "$9"},{"id": "10","name": "Item 10","price": "$10"}]}
1、怎么修改远程数据请求方法？
复制内容到剪贴板 程序代码<table data-toggle="table" data-url="data_json.asp" data-pagination="true" data-side-pagination="server" data-method="post">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
当method="get"(默认)时：data_json.asp?order=asc&offset=0&limit=10
当method="post"时：{"order":"asc","offset":0,"limit":10}
2、怎么添加服务器端查询参数？
复制内容到剪贴板 程序代码<table data-toggle="table" data-url="data_json.asp" data-pagination="true" data-side-pagination="server" data-query-params="queryParams">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
<script>
function queryParams(params) {
params.domain = "mzwu.com"
params.keyword = "abc"
return params
}
</script>
查询参数：data_json.asp?order=asc&offset=0&limit=10&domain=mzwu.com&keyword=abc
3、怎么修改分页参数类型？
复制内容到剪贴板 程序代码<table data-toggle="table" data-url="data_json.asp" data-pagination="true" data-side-pagination="server" data-query-params-type="limit">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
当type=“limit”(默认)时：data_json.asp?order=asc&offset=0&limit=10
当type=“”时：data_json.asp?sortOrder=asc&pageSize=10&pageNumber=1
相关链接
[1].Bootstrap Table官网：https://bootstrap-table.com/
[2].Bootstrap Table Examples：https://live.bootstrap-table.com/

+ 查看当前日志评论 (0)

登录

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.711 ms

返回

标题: Bootstrap Table服务器端分页使用示例

你没有权限发表评论

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.727 ms

返回

暂无评论

返回

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.742 ms

返回