layui table数据表格复选框勾选所有行数据获取的例子

飘逸的风3年前 (2023-02-02)前端510

最近项目中用到layui table数据表格复选框选中的数量要统计出来的功能,网上搜索了下,找到了解决办法,以下是示例:

html代码:

<table class="layui-table" lay-data="{url:'******', id:'test3'}" lay-filter="test3">
 
  <thead>
  <tr>
    <th lay-data="{type:'checkbox'}">ID</th>
    <th lay-data="{field:'id', width:80}">ID</th>
    <th lay-data="{field:'t1'}">测试项</th>
    <th lay-data="{field:'t2', edit: 'text'}">标定参数</th>
    <th lay-data="{field:'t3'}">标定值</th>
  </tr>
  </thead>
</table>



我们已经获取到了表中所有行的数据,全选,部分选都可行,不用选复选框遍历的方式去获取数据

table.on('checkbox(test3)', function(obj){
      var checkStatus = table.checkStatus('test3');
      console.log(checkStatus.data)//选中行数据
      console.log(checkStatus.data.length)
       
      })
       
$('.ttes').click(function () {
      var index = parent.layer.getFrameIndex(window.name);
      var checkStatus = table.checkStatus('test3');
      console.log(checkStatus.data)//选中行数据
      var items = checkStatus.data;


以上这篇layui-table表复选框勾选的所有行数据获取的例子了,希望能给大家一个参考。


原文链接:https://www.php1.cn/detail/layui-table_Biao_1f0da3ab.html

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。