参考链接
https://blog.csdn.net/Gino_tkzzz/article/details/84942012
https://blog.csdn.net/qq_39702981/article/details/105702967
步骤
页面中
table.render({
elem: "#followTable",
url: "{:url('statistics')}",
method:"post",
toolbar: '#toolbar',
width:1000,
page: true, // 重点
cols: [[
{field: "id", title: "ID", width: 80},
{field: "corp_name", title: "公司名称",width: 350},
{field: 'right', title: '操作', toolbar: '#barDemo'},
]],
parseData: function (res) {
var obj = eval("("+res+")");
return {
"code": 0,
"msg": "暂无数据",
"count": obj.count, // 重点
"data": obj.data
}
}
});
控制器中
//获取每页显示的条数
$limit= $request->param('limit');
//获取当前页码
$page= $request->param('page');
//limit的起始位置
$start=($page-1)*$limit;
$data = Db::name('zbqk') ->select();
$count = Db::name('zbqk') ->count();
$result = [
"code"=>0,
"count"=>$count,
'data'=>$data,
'msg'=>'操作成功'
];
return json_encode($result);