bootstrap table uncheckAll 反选所有行的方法,注如果有分页只会反选当前页,而不是选中全部页码的数据。
参数名称 | |
无 |
//取消选中当前页所有行
$('#table').bootstrapTable('uncheckAll');
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="https://www.itxst.com/package/jquery-3.3.1/jquery.js"></script>
<link href="https://www.itxst.com/package/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet" />
<link href="https://www.itxst.com/package/bootstrap-table-1.15.3/bootstrap-table.css" rel="stylesheet" />
<script src="https://www.itxst.com/package/bootstrap-table-1.15.3/bootstrap-table.js"></script>
<title>bootstrap table checkAll uncheckAll在线例子</title>
<style>
.table-demo {
width: 80%;
margin: 30px auto 0px auto;
}
.titles {
float: right;
clear: both;
}
</style>
</head>
<body>
<div id="toolbar">
<button onclick="check(1)">checkAll选中所有行</button>
<button onclick="check(2)">uncheckAll全选所有选中项</button>
</div>
<div class="table-demo">
<table id="table" ></table>
</div>
<script>
//定义列
var columns = [
{
checkbox:true
},
{
field:"Id",
title: 'ID'
}, {
field: 'fid',
title: 'Len'
} ];
var data= [{
Id: 1,
fid: 'B1',
}, {
Id: 2,
fid: 'B2',
}, {
Id: 3,
fid: 'B3',
} ];
$('#table').bootstrapTable({
toolbar:"#toolbar",
data:data,
columns: columns,
});
function check(icase)
{
if(icase===1)
{
$('#table').bootstrapTable('checkAll');
}
if(icase===2)
{
$('#table').bootstrapTable('uncheckAll');
}
}
</script>
</body>
</html>