1 Star 0 Fork 202

cc/layui-soul-table_1

forked from 叶落阁/layui-soul-table 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
font-table-page.html 4.85 KB
一键复制 编辑 原始数据 按行查看 历史
yelog 提交于 2023-05-24 23:04 . [升级] 升级并兼容 layui 版本 2.8.3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>layui-soul-table</title>
<meta name="keywords" content="layui,table,表头筛选,tablefilter,tableChild,子表,表格筛选"/>
<meta name="description" content="layui表头筛选,tablefilter,tableChild,子表,表格筛选"/>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="layui/css/layui.css" media="all"/>
<link rel="stylesheet" href="soulTable.css" media="all"/>
</head>
<body>
<div class="layui-row">
<div class="layui-col-lg3 layui-col-md4 layui-col-sm6">
<div class="layui-inline">
<label class="layui-form-label">诗词</label>
<div class="layui-input-inline" >
<input type="text" name="title"
class="layui-input" placeholder="请输入诗词关键字">
</div>
</div>
</div>
<div class="layui-col-lg3 layui-col-md4 layui-col-sm6">
<div class="layui-inline">
<label class="layui-form-label">内容</label>
<div class="layui-input-inline">
<input type="text" name="content"
class="layui-input" placeholder="请选择内容关键词">
</div>
</div>
</div>
<div class="layui-col-lg1 layui-col-md1 layui-col-sm2 layui-col-xs3">
<button class="layui-btn mgl-20" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i>查询</button>
</div>
<div class="layui-col-lg1 layui-col-md1 layui-col-sm2 layui-col-xs3">
<button class="layui-btn mgl-20" lay-submit="" lay-filter="export"><i class="layui-icon">&#xe615;</i>导出</button>
</div>
</div>
<table id="myTable" ></table>
<script type="text/html" id="author">
{{ d.author }} + 1
</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.8.0'
}).extend({ // 模块别名
soulTable: 'soulTable'
});
layui.use(['form', 'table','soulTable'], function () {
var table = layui.table,
soulTable = layui.soulTable,
$ = layui.$,
form = layui.form;
var myTable = table.render({
elem: '#myTable'
,height: $(document).height() - $('#myTable').offset().top - 20
,limit: 20
,page: true
,cols: [[
{type: 'checkbox', fixed: 'left'},
{field: 'title', title: '诗词', fixed:'left', width: 200, sort: true, filter: true, totalRowText: '合集'},
{field: 'dynasty', title: '朝代',fixed: 'left', width: 100, sort: true, filter: true, templet: '<div>{{d.dynasty}} + 2</div>'},
{field: 'author', title: '作者', width: 165 , filter: true, templet: '#author'},
{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, templet: function (d) {
return (d.heat||'') + ' +3'
}},
{field: 'createTime', title: '录入时间', width: 165,fixed:'right', filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true},
{title: '操作', width: 156,fixed:'right', templet: '#bar'}
]]
,done: function () {
soulTable.render(this)
}
});
search({});
function search(data) {
var loading = layer.load(2);
$.ajax({
url: 'data.json',
data: data,
dataType: 'json',
success: function (res) {
// myTable.reload({
// data: res.data
// })
table.reload('myTable', {
data: res.data
})
},
complete: function () {
layer.close(loading)
}
})
}
form.on('submit(search)', function (data) {
search(data.field);
})
form.on('submit(export)', function () {
soulTable.export(myTable);
})
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/cunqu/layui-soul-table_1.git
git@gitee.com:cunqu/layui-soul-table_1.git
cunqu
layui-soul-table_1
layui-soul-table_1
master

搜索帮助