layui獲取選中行數(shù)據(jù)的實(shí)例講解
更新時(shí)間:2018年08月19日 13:43:57 作者:BooleanIsTrue
今天小編就為大家分享一篇layui獲取選中行數(shù)據(jù)的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
第一步: 在jsp文件中設(shè)置按鈕
<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">驗(yàn)證是否全選</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}">財(cái)富</th> <th lay-data="{field:'score', width:80, sort: true, fixed: 'right'}">評(píng)分</th> <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th> </tr> </thead> </table>
第三步:寫(xiě)js,監(jiān)聽(tīng)事件
<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ù)的實(shí)例講解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
js中confirm實(shí)現(xiàn)執(zhí)行操作前彈出確認(rèn)框的方法
這篇文章主要介紹了js中confirm實(shí)現(xiàn)執(zhí)行操作前彈出確認(rèn)框的方法,是執(zhí)行刪除等操作時(shí)常用的功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-11-11- 下面就結(jié)合我自己的體會(huì)和所學(xué)習(xí)的東東和大家一起來(lái)學(xué)習(xí)在JS中如何使用面向?qū)ο蟮木幊獭?/div> 2011-08-08
分享9點(diǎn)個(gè)人認(rèn)為比較重要的javascript 編程技巧
接觸和學(xué)習(xí)javascript也有3~4年了,真正牽扯到前后臺(tái)數(shù)據(jù)的交互,數(shù)據(jù)算法等高級(jí)編程知之甚少,甚至很少用,如果你問(wèn)我你知道js什么知識(shí)呢?我可能只能說(shuō)知道點(diǎn)jQuery的技巧,說(shuō)編程都談不上,所以需要把某一些技巧作為編程習(xí)慣固定下來(lái),免于以后有人問(wèn)我你知道什么?2015-04-04常見(jiàn)瀏覽器多長(zhǎng)時(shí)間會(huì)提示“腳本運(yùn)行時(shí)間過(guò)長(zhǎng)”總結(jié)
這篇文章主要介紹了常見(jiàn)瀏覽器多長(zhǎng)時(shí)間會(huì)提示“腳本運(yùn)行時(shí)間過(guò)長(zhǎng)”總結(jié),需要的朋友可以參考下2014-04-04最新評(píng)論