layui獲取選中行數(shù)據(jù)的實(shí)例講解
更新時(shí)間:2018年08月19日 13:43:57 作者:BooleanIsTrue
今天小編就為大家分享一篇layui獲取選中行數(shù)據(jù)的實(shí)例講解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
第一步: 在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'}">評分</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ù)的實(shí)例講解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(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é)合我自己的體會和所學(xué)習(xí)的東東和大家一起來學(xué)習(xí)在JS中如何使用面向?qū)ο蟮木幊獭?/div> 2011-08-08
分享9點(diǎn)個人認(rèn)為比較重要的javascript 編程技巧
接觸和學(xué)習(xí)javascript也有3~4年了,真正牽扯到前后臺數(shù)據(jù)的交互,數(shù)據(jù)算法等高級編程知之甚少,甚至很少用,如果你問我你知道js什么知識呢?我可能只能說知道點(diǎn)jQuery的技巧,說編程都談不上,所以需要把某一些技巧作為編程習(xí)慣固定下來,免于以后有人問我你知道什么?2015-04-04
常見瀏覽器多長時(shí)間會提示“腳本運(yùn)行時(shí)間過長”總結(jié)
這篇文章主要介紹了常見瀏覽器多長時(shí)間會提示“腳本運(yùn)行時(shí)間過長”總結(jié),需要的朋友可以參考下2014-04-04最新評論

