天天看點

layui資料表格自定義複選框表頭_layui擷取表格資料table的複選框checkbox的所有id...

擷取選中ID

//擷取選中ID

function getIds()

{

var checkStatus = layui.table.checkStatus('demo'); //demo 即為基礎參數 id 對應的值

//console.log(checkStatus.data) //擷取選中行的資料即 多個行對象

//console.log(checkStatus.data.length) //擷取選中行數量,可作為是否有選中行的條件

//console.log(checkStatus.isAll ) //表格是否全選

if (checkStatus.data.length>0) {

var idsArray = [];

for (var i = 0; i < checkStatus.data.length; i++) {

idsArray.push(checkStatus.data[i].new_id);

}

var ids = idsArray.toString();

// console.log(ids);

layui.layer.alert(ids);

$(".layui-form-checked").not('.header').parents('tr').remove();

}

else

{

layui.layer.alert("請至少選擇一行");

}

}

layui.use(['layer', 'table'], function(){

var layer = layui.layer //彈層

,table = layui.table //表格

//向世界問個好

//layer.msg('Hello World');

//執行一個 table 執行個體

table.render({

elem: '#demo'

,height: 420

,url: './list2_json' //資料接口

,title: '使用者表'

,page: true //開啟分頁

,toolbar: 'default' //開啟工具欄,此處顯示預設圖示,可以自定義模闆,詳見文檔

,totalRow: true //開啟合計行

,cols: [ [ //表頭

{type: '', fixed: 'left'}

,{field: 'new_id', title: 'ID', width:80, sort: true, fixed: 'left'}

,{field: 'new_title', title: '标題', width:300}

,{field: 'new_menu', title: '類别', width:120}

,{field: 'new_order', title: '排序', width:80}

,{field: 'new_time', title: '添加時間', width: 130}

]]

});

});