我的数据表样式存在很大问题。 当扩展的列数时,我的数据表从我的bootstrap div中弹出。
注意:当我删除已过滤的列表时,该表响应良好。
这是我的html div:
<div class="responsive-table">
<table id="partnumber_table" class="table table-striped table-bordered display" width="100%" cellspacing="0">
<thead>
<tr>
<th>ID</th>
<th>Project (Z1)</th>
<th>Component (Z2)</th>
<th>Type (Z0)</th>
<th>Author</th>
<th>Date</th>
<th>Version (Z3)</th>
<th>Local</th>
<th>Part number</th>
<th></i></th>
<th></i></th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Project (Z1)</th>
<th>Component (Z2)</th>
<th>Type (Z0)</th>
<th>Author</th>
<th>Date</th>
<th>Version (Z3)</th>
<th>Local</th>
<th>Part number</th>
</tr>
</tfoot>
<tbody >
</tbody>
</table>
</div>
- 这是我的数据表的js代码。
table = $('#partnumber_table').DataTable( {
"data": results,
"columns": [
{ "data": "id" },
{ "data": "project" },
{ "data": "component" },
{ "data": "type" },
{ "data": "author" },
{ "data": "date" },
{ "data": "version" },
{ "data": "local" },
{ "data": "part_number" },
{
"className": 'update-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{
"className": 'delete-control',
"orderable": false,
"data": null,
"defaultContent": ''
}
],
initComplete: function () {
var select ;
var col_id=['Id','Project','Component','Type','Author','Date','Version','Local','Part_Number','update','delete'];
var type_input=['input','input','input','input','input','date','input','input','input'];
var index=0;
this.api().columns().every( function () {
id=col_id[index];
var column = this;
console.log(column);
select = $('<select style="width: 200px; float: left;" onchange="this.nextElementSibling.value=this.value"></option></select><input id="'+id+'" type="'+type_input[index]+'" style="width: 185px; margin-left: -199px; margin-top: 1px; border: none; float: left;"/>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
$( "#"+id ).on('input',function() {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
});
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
index++;
});
}
});
这也是我的css和js要求:
<link rel="stylesheet" type="text/css" href="asset/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="DataTables-1.10.12/css/dataTables.bootstrap.min.css"/>
<script type="text/javascript" src="jQuery-2.2.3/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="Bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="DataTables-1.10.12/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="DataTables-1.10.12/js/dataTables.bootstrap.min.js"></script>
<script src="asset/js/jquery.ui.min.js"></script>
<script src="asset/js/bootstrap.min.js"></script>
我附上了描述我丑陋视图的截图。 My table pop out from the bootsrap div 请问,我该如何解决这个问题?