HttpClientHelper helper = new HttpClientHelper("http://localhost:58185/");
public IActionResult GetSection(int page = 0,int limit = 0)
{
string json = helper.Get("api/Section/GetSection");
List<Section> list = JsonConvert.DeserializeObject<List<Section>>(json);
var Result = list.Skip((page-1) * limit).Take(limit);
return Json(new Layui {
code = "0",
msg = "成功",
count = (list.Count).ToString(),
data = Result
});
}
public IActionResult SectionView ()
{
return View();
}
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>部门 - 显示</title>
<link href="~/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
<script src="~/layui-v2.5.6/layui/layui.js"></script>
</head>
<body>
<table class="layui-hide" id="test"></table>
</body>
</html>
<script>
layui.use('table', function () {
var table = layui.table;
table.render({
elem: '#test'
, url: '/Section/GetSection'
, limit: 5
, limits: [5, 10, 20, 30, 40, 50]
, layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
, theme: '#FF5722'
, first: '首页'
, last: '末页'
, cols: [[
{ field: 'sId', width: 100, title: '编号', sort: true }
, { field: 'sName', width: 100, title: '用户名' }
]]
, page: true
});
});
</script>