<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.4</version>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>
@Override
public BootstrapTableResult<Netbar> findUserByPagination(int offset, int limit, Netbar netbar) {
// 这句要在查询之前
PageHelper.startPage((offset / limit) + 1, limit);
List<Netbar> list = findNetbarList(netbar);
PageInfo<Netbar> pageInfo = new PageInfo<Netbar>(list);
BootstrapTableResult<Netbar> result = new BootstrapTableResult<Netbar>();
result.setTotal(pageInfo.getTotal());
result.setRows(pageInfo.getList());
return result;
}
// 表格初始化
$('#table').bootstrapTable({
pagination: true,
showColumns: true,//是否显示所有的列(选择显示的列)
pageSize: 10,
pageNumber: 1,//初始化加载第一页,默认第一页,并记录
pageList: [10, 25, 50],
showRefresh: true,
smartDisplay: false,
singleSelect: true, // 单选checkbox
clickToSelect: true,//是否启用点击选中行
uniqueId: 'id',//每一行的唯一标识,一般为主键列
method: 'get',
url: '/sys/netbar/manage/list/data',
dataType: 'json',
sidePagination: 'server',//分页方式:client客户端分页,server服务端分页(*)
toolbar: '#toolbar',
queryParams: function (params) {
var params = {
offset: params.offset, //数据起始
limit: params.limit, //偏移量
netbarName: $("#netbarName").val(),
netbarNo: $("#netbarNo").val(),
areaCode: $("#area").val()
};
return params;
},
columns: [{
checkbox: true
}, {