溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

layui獲取選中行數(shù)據(jù)的實例講解

發(fā)布時間:2020-08-30 02:54:43 來源:腳本之家 閱讀:1093 作者:BooleanIsTrue 欄目:web開發(fā)

第一步: 在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">驗證是否全選</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ù)的實例講解就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持億速云。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI