Skip to content

Commit cea3f19

Browse files
committed
fix: restore HTML datatable scroll and print layout
- remove forced table width so scrollX can size columns - allow overflow-x only on screen and expand tables for print - adjust columns on window resize to keep headers aligned
1 parent 84be741 commit cea3f19

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

dqgen/resources/html_templates/static/layout.html

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}
6464

6565
table.display {
66-
width: 100% !important;
66+
width: auto;
6767
min-width: 100%;
6868
}
6969

@@ -72,11 +72,15 @@
7272
visibility: hidden;
7373
}
7474

75-
#print-container {
76-
width: 100% !important;
77-
position: absolute;
78-
left: 0;
79-
top: 0;
75+
#print-container,
76+
.dataTables_wrapper,
77+
.dataTables_scrollHead,
78+
.dataTables_scrollBody {
79+
overflow: visible !important;
80+
width: auto !important;
81+
}
82+
table.display {
83+
width: auto !important;
8084
}
8185

8286
footer {
@@ -130,15 +134,18 @@ <h1 class="ui header center aligned reportTitle" id="skip-toc">{{ conf.title }}<
130134
<script type="text/javascript">
131135
$(document).ready(function () {
132136

133-
$("table.display").DataTable({
137+
const table = $("table.display").DataTable({
134138
dom: 'B<"clear">lfrtip',
135-
buttons: [
136-
'print'
137-
],
138-
"lengthMenu": [[5, 15, 30, -1], [5, 15, 30, "All"]],
139+
buttons: ['print'],
140+
lengthMenu: [[5, 15, 30, -1], [5, 15, 30, "All"]],
139141
scrollX: true,
140142
autoWidth: false
141143
});
144+
145+
$(window).on('resize', function () {
146+
table.columns.adjust();
147+
});
148+
142149
$("h2").each(function () {
143150
if (!$(this).next().is("section") && !$(this).next().is("h3") && !$(this).next().hasClass("dataTables_wrapper")) {
144151
$(this).remove();

0 commit comments

Comments
 (0)