【发布时间】:2017-02-08 13:58:01
【问题描述】:
使用数据表加载我的 Web 应用程序页面时,数据表已加载,但 <thead> 行不是表的全宽。
编辑数据后,或在数据表搜索中搜索,表头跳转到全宽。见图片。
对此有任何解决方案或解决方法吗?
数据表截图:
我的普通数据表很好,但是这个是在模式中加载的。 代码模态:
<!-- Get selected shops modal -->
<div id="SelectedShopsModal" class="infomodal">
<div class="shops-content">
<h2><span class="closeModalSelectedShops">×</span> <?php echo lang('Shops'); ?></h2>
<div class="detailblock">
<table id="DataListTableSelectedShops" class="display" cellspacing="0" width="100%">
<thead>
<th class="OE"><?php echo lang('Shop_No'); ?></th>
<th class="OE"><?php echo lang('Shop_Name'); ?></th>
<th class="OE"><?php echo lang('Shop_District'); ?></th>
</thead>
<tbody>
<?php foreach($selected_shops as $shop){
echo "<tr><td>" . $shop['Shop'] . "</td><td>" . $shop['Name'] . "</td><td>" . $shop['District'] . "</td></tr>";
} ?>
</tbody>
</table>
<br /><button class="closeBtnSelectedShops btn red"><?php echo lang('Close'); ?></button>
<button class="btn red" onclick="delete_oneshots();"><i class="fa fa-trash" aria-hidden="true"></i> <?php echo lang('Delete_shops'); ?></button>
</div>
</div>
</div>
我在页面页脚中使用的 javascript:
//datatable to display all selected shops on detail page
selectedshoptable = $('#DataListTableSelectedShops').DataTable( {
"dom": "Bfrtip",
"scrollY": "300px",
"scrollCollapse": true,
"bPaginate": false,
"bInfo" : false,
"fields": [ {
label: "Shopnr",
name: "Shop"
}, {
label: "Shopname:",
name: "Name"
}, {
label: "District",
name: "District"
}],
"buttons":[{
extend: 'selectAll',
text: '<?php echo lang('Select_all'); ?>',
className: 'btn red'
}, {
text: '<?php echo lang('Select_none'); ?>',
className: 'btn red',
action: function () {
selectedshoptable.rows().deselect();
}
}],
"language": {
"zeroRecords": "<?php echo lang('Nothing_found'); ?>",
"infoEmpty": "<?php echo lang('No_records_available'); ?>",
"search":"<?php echo lang('Search'); ?>",
"buttons": {"selectNone": "Select none"}
}
});
【问题讨论】:
-
你能把你的代码贴在这里吗?
-
嗨,大卫,我的代码已添加。
标签: javascript datatables header modal-dialog