layui数据表格的按钮事件

可以参考layui官网
https://www.layuiweb.com/demo/table/form.html

在这里插入图片描述
获取的数据:

table.render({
                elem: '#test'
                , url: '/StoreServlet/get'/*tpa=https://www.layuiweb.com/test/table/demo1.json*/
                , where: {"name": name, "address": address}
                , toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
                , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
                    title: '提示'
                    , layEvent: 'LAYTABLE_TIPS'
                    , icon: 'layui-icon-tips'
                }]
                , title: '用户数据表'
                , cols: [[
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'roomcode', title: '门店编号', width: 100, sort: true}
                    , {field: 'storename', title: '门店名称', width: 120, edit: 'text'}
                    , {field: 'store_location', title: '门店地址', width: 200}
                    , {field: 'status', title: '门店状态', width: 150,templet: '#switchTpl', unresize: true}
                    , {
                        field: 'create_time',
                        title: '创建时间',
                        width: 350,
                        templet: "<div>{{layui.util.toDateString(d.create_time, 'yyyy年-MM月-dd日 HH:mm:ss')}}</div>"
                    }
                    , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
                    // , {fixed: 'store_location', title: '门店地址', toolbar: '#barDemo', width: 150}
                ]]

在页面加入

<script type="text/html" id="switchTpl">
            <!-- 这里的 checked 的状态只是演示           value="{{d.id}}" 是将id的值 传单点击的事件  d为当前点击的对象      -->
            <input type="checkbox" name="sex" value="{{d.id}}" lay-skin="switch" lay-text="正常|闭店" lay-filter="statusDemo" {{ d.status == 0 ? 'checked' : '' }}>
        </script>

点击触发的事件

 //监听状态操作  点击时触发
        form.on('switch(statusDemo)', function(obj){
            alert("点击"+this.value)
            layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);
        });
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杵意

谢谢金主打赏呀!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值