bootstrap table toggleView把列表模式切换到卡片视图模式。
参数名称 | |
无 |
//隐藏或显示分页器
$('#table').bootstrapTable('toggleView');
<!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 toggleView在线例子</title>
<style>
.table-demo {
width: 80%;
margin: 30px auto 0px auto;
}
.fixed-table-header {
border-right: solid 1px #ddd;
border-top: solid 1px #ddd;
}
.fixed-table-header table {
border-top: solid 0px #ddd !important;
margin-top:-1px;
}
</style>
</head>
<body >
<div id="toolbar">
<button class="btn btn-secondary" onclick="act()">切换卡片视图</button>
</div>
<div class="table-demo">
<table id="table"></table>
</div>
<script>
//设置列
var columns = [
{checkbox:true},{
field: 'Id',
title: 'ID'
}, {
field: 'Food',
title: '食物'
}, {
field: 'WW',
title: '销量'
}];
//bootstrap table初始化数据
$('#table').bootstrapTable({
toolbar:"#toolbar",
columns: columns,
data: getData(),
classes: "table table-bordered table-striped table-sm", //设置表格样式
height:500,
});
function getData()
{
var data = [];
for (var i = 0; i < 10; i++)
{
var item = {
Id: i,
Food: '苹果',
WW: i+1000
};
data.push(item);
};
return data;
}
function act()
{
$('#table').bootstrapTable('toggleView')
}
</script>
</body>
</html>