$('#table').bootstrapTable({
height:323,
classes:'table table-xkap table-hover',
columns: [
{checkbox:true,width:'5%'},
{field: 'id',title: '标识列',visible:false},
{field: 'userid',title: '用户标识',align:'center',width:'20%'},
{field: 'username',title: '姓名',align:'center',width:'10%'},
{field: 'deviceid',title: '设备标识',align:'center',width:'20%'},
{field: 'sleeptime',title: '始睡时间',align:'center',width:'20%'},
{field: 'getuptime',title: '起床时间',align:'center',width:'20%'},
{field: 'score',title: '睡眠评分',align:'center',width:'10%'}
],
idField:'id',
uniqueId:'id',
url: "data/isleep/data01.json",
pagination:true,
pageSize:5,
pageList:[5,10,'ALL'],
selectItemName:'id',
clickToSelect:true,
toolbar: "#source-toolbar",
toolbarAlign:'right'
});
$('#table1').bootstrapTable({
height:275,
classes:'table table-xkap table-hover',
columns: [
{checkbox:true,width:'5%'},
{field: 'id',title: '标识列',visible:false},
{field: 'userid',title: '用户标识',align:'center',width:'20%'},
{field: 'username',title: '姓名',align:'center',width:'5%'},
{field: 'deviceid',title: '设备标识',align:'center',width:'20%'},
{field: 'sleeptime',title: '始睡时间',align:'center',width:'20%'},
{field: 'getuptime',title: '起床时间',align:'center',width:'20%'},
{field: 'score',title: '睡眠评分',align:'center',width:'10%'}
],
idField:'id',
uniqueId:'id',
selectItemName:'id',
clickToSelect:true
});
$("#btn_select").on("click",function(){
$("#table1").bootstrapTable("uncheckAll");
var data = $("#table").bootstrapTable("getAllSelections");
//$("#table1").bootstrapTable("appendByUniqueId",data);
$("#table1").bootstrapTable("append",data);
});
$("#btn_test").click(function(){
//在table1中取消选中后,即使table中对应数据是选中状态也不会被获取
var data = $("#table").bootstrapTable("getAllSelections");
console.log(data.length);
});