layui獲取選中行數(shù)據(jù)的實例講解
更新時間:2018年08月19日 13:43:57 作者:BooleanIsTrue
今天小編就為大家分享一篇layui獲取選中行數(shù)據(jù)的實例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
第一步: 在jsp文件中設置按鈕
<div class="layui-btn-group demoTable"> <button class="layui-btn" data-type="getCheckData">獲取選中行數(shù)據(jù)</button> <button class="layui-btn" data-type="getCheckLength">獲取選中數(shù)目</button> <button class="layui-btn" data-type="isAll">驗證是否全選</button> </div>
第二步:在jsp文件中創(chuàng)建表格
<table class="layui-table" lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo"> <thead> <tr> <th lay-data="{type:'checkbox', fixed: 'left'}"></th> <th lay-data="{field:'id', width:80, sort: true, fixed: true}">ID</th> <th lay-data="{field:'username', width:80}">用戶名</th> <th lay-data="{field:'sex', width:80, sort: true}">性別</th> <th lay-data="{field:'city', width:80}">城市</th> <th lay-data="{field:'sign', width:160}">簽名</th> <th lay-data="{field:'experience', width:80, sort: true}">積分</th> <th lay-data="{field:'classify', width:80}">職業(yè)</th> <th lay-data="{field:'wealth', width:135, sort: true}">財富</th> <th lay-data="{field:'score', width:80, sort: true, fixed: 'right'}">評分</th> <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th> </tr> </thead> </table>
第三步:寫js,監(jiān)聽事件
<script> layui.use('table', function(){ var table = layui.table; var $ = layui.$, active = { getCheckData: function(){ //獲取選中數(shù)據(jù) var checkStatus = table.checkStatus('idTest') ,data = checkStatus.data; layer.alert(JSON.stringify(data)); } }; </script>
以上這篇layui獲取選中行數(shù)據(jù)的實例講解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
js中confirm實現(xiàn)執(zhí)行操作前彈出確認框的方法
這篇文章主要介紹了js中confirm實現(xiàn)執(zhí)行操作前彈出確認框的方法,是執(zhí)行刪除等操作時常用的功能,非常具有實用價值,需要的朋友可以參考下2014-11-11