From 4f80658c38a2a0803dc421c8101b18e99dc76ddd Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Tue, 10 Sep 2019 07:46:07 +0200 Subject: [PATCH 1/2] ITSTYR-63: Add affix and styling. --- public/styles.css | 9 ++++++++- templates/easy_admin_overrides/list.html.twig | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/public/styles.css b/public/styles.css index 968cd46..11df881 100644 --- a/public/styles.css +++ b/public/styles.css @@ -104,7 +104,7 @@ body.list table tbody td.dashboard--table-answer { } .dashboard--table { - overflow-x: auto; + /* overflow-x: auto; */ } .dashboard--last-column { @@ -153,3 +153,10 @@ body.list table tbody td.dashboard--table-answer { margin-top: 2em; margin-bottom: 2em; } + + +/* Fix position of table heads while scrolling */ +.affix { + top: 0; + z-index: 1040; +} \ No newline at end of file diff --git a/templates/easy_admin_overrides/list.html.twig b/templates/easy_admin_overrides/list.html.twig index 104c416..05b5b2e 100644 --- a/templates/easy_admin_overrides/list.html.twig +++ b/templates/easy_admin_overrides/list.html.twig @@ -128,5 +128,24 @@ }); } }, false); + + // Function for setting static size on table heads. We need to do this to keep the same width as the table when setting the theads position to fixed. + // One could argue that we should use position sticky instead. But since we manipulate overflow on thead parents that can't be done. + function setTheadSize() { + // Set width of thaed + $("table thead").each(function() { + $(this).width($(this).width()); + }); + // Set the with of the column headers in thead + $("table thead th").each(function() { + $(this).width($(this).width()); + }); + // Affix table header when this reaches upper borwser edge. + $('table thead').affix({ + offset: 0 + }) + } + window.addEventListener('resize', setTheadSize); + setTheadSize(); {% endblock %} From 98df414c4b008062dc50add5c0282f8e209e38b6 Mon Sep 17 00:00:00 2001 From: Jesper Pedersen Date: Tue, 10 Sep 2019 07:49:13 +0200 Subject: [PATCH 2/2] ITSTYR-63: Should not be outcommented. --- public/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/styles.css b/public/styles.css index 11df881..2de9714 100644 --- a/public/styles.css +++ b/public/styles.css @@ -104,7 +104,7 @@ body.list table tbody td.dashboard--table-answer { } .dashboard--table { - /* overflow-x: auto; */ + overflow-x: auto; } .dashboard--last-column {