迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:layui-soul-table开源软件地址:https://gitee.com/saodiyang/layui-soul-table开源软件介绍:给 layui-table 注入点灵魂当前layui版本 在线demo及文档: https://saodiyang.gitee.io/layui-soul-table 国内下载地址: https://gitee.com/saodiyang/layui-soul-table 扩展功能
效果1.表头筛选效果2.编辑筛选效果筛选 3.拖动列调整顺序、隐藏显示列左右拖动调整顺序,鼠标移出表格后松开--快速隐藏列 4.子表快速上手1.将下面模块放到自己项目中:
源码版位置: 2.定义入口模块 // 自定义模块,这里只需要开放soulTable即可layui.config({ base: 'ext/', // 模块目录}).extend({ soulTable: 'soulTable' // 模块别名}); 3.引入 4.在 table.render({ elem: '#myTable' ,height: $(document).height() - $('#myTable').offset().top - 20 ,limit: 20 ,page: true ,cols: [[ {type: 'checkbox', fixed: 'left'} ,{field:'poetry', title:'诗词', width:188, filter:true, sort: true} ,{field:'name', title:'诗人', width:100, filter:true, sort: true} ,{field:'type', title:'类型', width:100, filter:true} ,{field:'dynasty', title:'朝代', width:150, filter:true} ,{field:'sentences', title:'名句', width:400, filter:true} ,{title:'操作', toolbar: '#barDemo', width:150} ]] ,done: function () { soulTable.render(this) }}); 详细介绍一、支持使用的几种情况demo 中都有示例
二、筛选相关
1.时间类型增强, var myTable = table.render({ ... ,cols: [[ ... ,{field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true} ... ]] ,done: function () { soulTable.render(this) }}); 2.调整下拉菜单的顺序、显示(去掉下面数组的某一项即可隐藏)此 var myTable = table.render({ ... cols: [[ ... ]] , filter: { //用于控制表头下拉显示,可以控制顺序、显示, 依次是:表格列、筛选数据、筛选条件、编辑筛选条件、导出excel items:['column','data','condition','editCondition','excel'] } , done: function (res, curr, count) { soulTable.render(this) }}); 3.隐藏底部筛选区域,默认为 var myTable = table.render({ ... cols: [[ ... ]] , filter: { bottom: false } , done: function (res, curr, count) { soulTable.render(this) }}); 三、后台筛选目前支持 四、导出excel相关1.配置默认样式
五、子表1⃣️ 开启配置
2⃣️ 子表参数
3⃣️ 示例var myTable = table.render({ elem: '#myTable' ,height: $(document).height() - $('#myTable').offset().top - 20 ,limit: 30 ,page: true ,cols: [[ {title: '#', width: 50, children:[ { title: '表格一' ,url: 'data.json' ,height: 300 ,limit: 10000000 ,page: false ,toolEvent: function (obj) { if (obj.event === 'childEdit') { layer.open({ type: 1, title: '子表1-编辑', shadeClose: true, content:obj.data }); } else if (obj.event === 'childDel') { layer.open({ type: 1, title: '子表1-删除', shadeClose: true, content: obj.data }); } } ,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}, {field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true}, {title: '操作', width: 156, templet: '#childBar'} ]] ,done: function () { soulTable.render(this); } }, { title: '表格二' ,height: 300 ,limit: 1000000 ,data: function (d) { // d 为当前行数据 console.log(d); return [d]; } ,toolEvent: function (obj) { if (obj.event === 'childEdit') { layer.open({ type: 1, title: '子表2-编辑', shadeClose: true, content:obj.data }); } else if (obj.event === 'childDel') { layer.open({ type: 1, title: '子表2-删除', shadeClose: true, content:obj.data }); } } ,page: false ,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}, {field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true}, {title: '操作', width: 156, templet: '#childBar'} ]] ,done: function () { soulTable.render(this); } } ]}, {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}, {field: 'createTime', title: '录入时间', width: 165, filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true}, {title: '操作', width: 156, templet: '#bar'} ]] ,done: function () { soulTable.render(this) }});
var myTable = table.render({ ... , cols: [[ ... ]] , excel:{ // 导出excel配置, (以下值均为默认值) on: true, //是否启用, 默认开启 filename: '诗词.xlsx', // 文件名 head:{ // 表头样式 family: 'Calibri', // 字体 size: 12, // 字号 color: '000000', // 字体颜色 bgColor: 'C7C7C7' // 背景颜色 }, font: { // 正文样式 family: 'Calibri', // 字体 size: 12, // 字号 color: '000000', // 字体颜色 bgColor: 'FFFFFF' //背景颜色 } } , done: function (res, curr, count) { soulTable.render(this) }}); 内置方法1.渲染入口render()
2.excel导出export()除了开启下拉列表中的 <a class="layui-btn" id="export">导出</a><script> layui.use(['form', 'soulTable', 'table'], function () { ... var myTable = table.render({ ... , done: function (res, curr, count) { soulTable.render(this) } }); $('#export').on('click', function() { soulTable.export(myTable); }) })</script> 依赖项目
最后当然具体的可以clone下来代码查看,有问题可以在 issue 区提问,我会尽可能快的回复。 ![]() |
2022-08-15
2022-08-17
2023-10-27
2022-09-23
2022-08-13
请发表评论