bootstrap table hideAllColumns隐藏所有列。
参数名称 | |
无 |
//隐藏所有的列
$('#table').bootstrapTable('hideAllColumns');
<!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 showAllColumns hideAllColumns在线例子</title>
<style>
.table-demo {
width: 80%;
margin: 30px auto 0px auto;
}
.titles {
float: right;
clear: both;
}
</style>
</head>
<body>
<div id="toolbar">
<button onclick="col(2)">隐藏所有列</button>
<button onclick="col(1)">显示所有列</button>
</div>
<div class="table-demo">
<table id="table" ></table>
</div>
<script>
//设置需要显示的列
var columns = [
{
checkbox:true
},
{
field:"Id",
title: 'ID'
}, {
field: 'clog',
title: '目录'
} ];
var data= [{
Id: 1,
clog: '目录 A1',
}, {
Id: 2,
clog: '目录 A2',
}, {
Id: 3,
clog: '目录 A3',
} ];
$('#table').bootstrapTable({
toolbar:"#toolbar",
data:data,
columns: columns,
});
$('#table').bootstrapTable('hideColumn','clog');
function col(icase)
{
if(icase===1)
{
$('#table').bootstrapTable('showAllColumns','clog');
}
if(icase===2)
{
$('#table').bootstrapTable('hideAllColumns','clog');
}
}
</script>
</body>
</html>