【发布时间】:2016-07-06 19:09:33
【问题描述】:
我正在尝试创建一个带有 3 个选项卡的引导选项卡式 div,每个选项卡都有自己的表(3 个单独的数据表 - https://datatables.net)。我已经初始化了 3 个表并对其进行了测试,但是当我使用虚拟文本/值创建其中 2 个表时,第二个表会缩小,因此它不适合整个宽度。当我初始化没有数据的表时不会发生这种情况,并且第一个表似乎总是按要求工作,全宽,无论它是否用数据初始化。我似乎看不出为什么连续的表格没有全宽显示。任何帮助深表感谢。干杯。
HTML
<div class="row">
<div class="col-lg-12">
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#sent" aria-controls="sent" role="tab" data-toggle="tab">Sent</a></li>
<li role="presentation"><a href="#received" aria-controls="received" role="tab" data-toggle="tab">Received</a></li>
<li role="presentation"><a href="#completed" aria-controls="completed" role="tab" data-toggle="tab">Completed</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="sent">
<br>
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover quotes" id="sentTable">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Reply</th>
<th>Date Created</th>
<th>Last Updated</th>
<th>Quote</th>
</tr>
</thead>
</table>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="received">
<br>
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover quotes" id="receivedTable">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Reply</th>
<th>Date Created</th>
<th>Last Updated</th>
<th>Quote</th>
</tr>
</thead>
</table>
</div>
<!-- /.table-responsive -->
</div>
<div role="tabpanel" class="tab-pane" id="completed">
<br>
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover quotes" id="completedTable">
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Reply</th>
<th>Date Created</th>
<th>Last Updated</th>
<th>Quote</th>
</tr>
</thead>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
</div>
</div>
<!-- /.col-lg-12 -->
JavaScript
$(document).ready(function() {
$('#sentTable').DataTable( {
"columns": [
{ "data": "title" },
{ "data": "description" },
{ "data": "reply" },
{ "data": "datecreated" },
{ "data": "dateupdated" },
{ "data": "quote" }
],
"data": [{
"title":"mytitle",
"description":"mydescription",
"reply":"cvfsdfgsdfg",
"datecreated":"2016-07-06 09:20:56",
"dateupdated":"2016-07-06 15:57:01",
"quote":"100"
}]
} );
$('#receivedTable').DataTable( {
"columns": [
{ "data": "title" },
{ "data": "description" },
{ "data": "reply" },
{ "data": "datecreated" },
{ "data": "dateupdated" },
{ "data": "quote" }
],
"data": [{
"title":"mytitle",
"description":"mydescription",
"reply":"cvfsdfgsdfg",
"datecreated":"2016-07-06 09:20:56",
"dateupdated":"2016-07-06 15:57:01",
"quote":"100"
},
{
"title":"mytitle",
"description":"mydescription",
"reply":"the best reply by far.",
"datecreated":"2016-07-06 09:34:59",
"dateupdated":"2016-07-06 15:57:26",
"quote":"56"
}]
} );
$('#completedTable').DataTable( {
"columns": [
{ "data": "title" },
{ "data": "description" },
{ "data": "reply" },
{ "data": "datecreated" },
{ "data": "dateupdated" },
{ "data": "quote" }
]
} );
} );
【问题讨论】:
标签: jquery html css twitter-bootstrap datatables