-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathrunjs.html
68 lines (64 loc) · 2.38 KB
/
runjs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>在线调试</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="layui/css/layui.css" media="all"/>
<link rel="stylesheet" href="soulTable.css" media="all"/>
</head>
<body>
<table id="myTable" ></table>
<script type="text/html" id="toolbar">
<div><button class="layui-btn layui-btn-sm" lay-event="clearFilter">清除所有筛选条件</button></div>
</script>
<script type="text/html" id="bar">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript" src="layui/layui.js"></script>
<script>
// 自定义模块
layui.config({
base: 'ext/', // 模块目录
version: 'v1.9.1'
}).extend({ // 模块别名
soulTable: 'soulTable'
});
layui.use(['form', 'table','soulTable'], function () {
var table = layui.table,
soulTable = layui.soulTable;
// 后台分页
table.render({
elem: '#myTable'
,id: 'myTable'
,url: 'https://soultable.saodiyang.com/layui-soul-table-java/poetry/dataGrid'
,height: 500
,toolbar: '#toolbar'
,page: true
,cols: [[
{type: 'checkbox', fixed: 'left'},
{field: 'title', title: '诗词', width: 200, sort: true, filter: true},
{field: 'dynasty', title: '朝代', width: 100, sort: true, filter: true},
{field: 'author', title: '作者', width: 165 , filter: true},
{field: 'type', title: '类型', width: 112, filter: {split:','}, sort:true},
{field: 'content', title: '内容', width: 823, filter: true},
{field: 'heat', title: '点赞数', width: 112, filter: true, sort:true, excel:{cellType: 'n'}},
{field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true},
{title: '操作', width: 156, fixed: 'right', templet: '#bar'}
]]
,done: function () {
soulTable.render(this)
}
});
table.on('toolbar(myTable)', function(obj){
if (obj.event === 'clearFilter') {
// 清除所有筛选条件并重载表格
// 参数: tableId
soulTable.clearFilter('myTable')
}
});
}, null, 'define')
</script>
</body>
</html>