layui扩展组件—— soulTable之编辑筛选条件隐藏

原图

在这里插入图片描述
在这里插入图片描述

我的需求:

隐藏表右下角的编辑筛选条件样式,需要的样式如下图:

在这里插入图片描述

jsp代码:

 <style>
        .soul-bottom-contion {
            height: 31px;
            /*line-height: 29px;*/
            border-top: solid 1px #e6e6e6;
            display:none;
        }
        .soul-bottom-contion .condition-items {
            display: inline-block;
            width: calc(100vw - 100px);
            height: 30px;
            float: left;
            /*overflow: hidden;*/
            white-space: nowrap;
            display:none;
        }
 </style>

 layui.config({
        base: '/static/layui-v2.5.6/ext/',// 第三方模块所在目录
        version: 'v1.5.10' // 插件版本号
    }).extend({
        soulTable: 'soulTable/soulTable',
        tableChild: 'soulTable/tableChild',
        tableMerge: 'soulTable/tableMerge',
        tableFilter: 'soulTable/tableFilter',
        excel: 'soulTable/excel'
    });

 layui.use(['form', 'table','soulTable'], function () {
    table.render({
        elem: '#myTable'
        ,id: 'myTable'
        ,url: 'data.json'
        ,height: 500
        ,toolbar: '#toolbar'
        ,page: false
        //filter为添加部分------------
        ,filter:{
                items:['colum','data','condition','editCondition'],  // 控制漏斗的操作功能
                bottom:false
            },
        //filter为添加部分------------
        ,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: 'content', title: '内容', width: 123, filter: true},
            {field: 'type', title: '类型', width: 112,  filter: {split:','}, sort:true},
            {field: 'heat', title: '点赞数', width: 112,  filter: true, fixed: 'right', sort:true, excel:{cellType: 'n'}},
            {field: 'createTime', title: '录入时间', width: 165, fixed: 'right', filter: {type: 'date[yyyy-MM-dd HH:mm:ss]'}, sort:true},
        ]]
        ,
        //done为添加部分----------------
         done: function (res, curr, count) {
                layui.soulTable.render(this)
            }
        //done为添加部分----------------
    });
})

链接:

官网文档链接:layui-soul-table

layui 表格中,可以通过监听复选框的选择来实现批量操作等功能。具体实现步骤如下: 1. 在表格中添加复选框列,并设置lay-skin属性为primary,表示使用layui风格的复选框。 ``` <table class="layui-table" lay-data="{...}"> <colgroup> ... <col width="50"> </colgroup> <thead> ... <th lay-data="{field:'checkbox', width:50, templet:'#checkboxTpl'}"></th> </thead> <tbody> ... </tbody> </table> <script type="text/html" id="checkboxTpl"> <input type="checkbox" lay-skin="primary"> </script> ``` 2. 在JavaScript代码中监听复选框的选择事件,可以使用layui的form模块来实现。需要注意的是,由于表格是动态生成的,所以需要使用layui的form.render()方法重新渲染表单元素。 ``` layui.use(['table', 'form'], function(){ var table = layui.table, form = layui.form; // 监听复选框选择 table.on('checkbox(test)', function(obj){ console.log(obj.checked); // 当前是否选中状态 console.log(obj.data); // 原始数据 console.log(obj.type); // 类型,如果行选则为:row,如果全选则为:all,如果取消选择则为:uncheck console.log(table.checkStatus('test').data); // 获取选中行的数据 }); // 重新渲染表单元素 form.render(); }); ``` 3. 表格中如果存在分页,则需要在分页时重新渲染表单元素。 ``` table.on('page(test)', function(){ form.render(); }); ``` 以上就是监听表格复选框选择的实现方法。需要注意的是,表格中的复选框列必须有唯一的字段名,否则无法在JavaScript代码中获取选中行的数据。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值