【发布时间】:2014-12-17 11:07:39
【问题描述】:
我正在使用最新的 Datatables.net,带有数据表和引导程序。我想我的问题是:Datatables Responsive Bootstrap 使用什么来检测溢出,因为它显然不是父宽度。
这是我的结果:
这是一个非常简单的问题。如果我将窗口的宽度再减小 1 个像素,则该列最终将折叠。如果我然后展开它,它会返回到这个状态。我想防止父引导面板溢出。我已经删除了引导网格 div(行/col-xs-12 等)以消除潜在问题,但是一旦解决了这个问题(或者我更好地理解了问题),我也打算使用引导网格系统。
这是一个完美复制问题的 plunkr(折叠运行视图): http://plnkr.co/edit/tZxAMOHmdoHNHrzhP5tR?p=preview
<!DOCTYPE html>
<html>
<head>
<title>Tables - PixelAdmin</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
<link rel="stylesheet" href="http://cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.css"/>
<link rel="stylesheet" href="http://cdn.datatables.net/responsive/1.0.2/css/dataTables.responsive.css"/>
<style>
body {
font-size: 140%;
}
table.dataTable th,
table.dataTable td {
white-space: nowrap;
}
</style>
</head>
<body style="padding-top: 40px;">
<div class="panel panel-primary" style="margin: 51px; padding: 0;">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body" style="padding: 0;">
<div style="width: 100%; border: 1px solid red;">
<table id="example" class="table table-striped table-hover dt-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Extn.</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/responsive/1.0.2/js/dataTables.responsive.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.js"></script>
<script>
$(document).ready(function () {
$('#example')
.dataTable({
"responsive": true,
"ajax": 'data.json'
});
});
</script>
</body>
</html>
【问题讨论】:
-
对我来说,这个答案解决了问题:stackoverflow.com/a/1544925/5921762
-
我现在遇到了同样的问题stackoverflow.com/questions/44586271/…。你找到解决办法了吗?
标签: jquery twitter-bootstrap responsive-design datatables