",
+ 'type': "natural-minus-na",
+ 'width': "120px",
+ 'data': "location"
+ }{% endif %}
];
loadDataTable();
function loadDataTable(){
+
+ setUserColumnsDefWidths();
+
//ZS: Need to make sort by symbol, also need to make sure blank symbol fields at the bottom and symbols starting with numbers below letters
trait_table = $('#' + tableId).DataTable( {
'drawCallback': function( settings ) {
@@ -391,7 +404,8 @@
"deferRender": true,
"bSortClasses": false,
{% if trait_list|length > 20 %}
- "scrollY": "100vh",
+ "scrollY": "500px",
+ "scrollX": true,
"scroller": true,
"scrollCollapse": true,
{% else %}
@@ -411,6 +425,10 @@
} );
}
+ window.addEventListener('resize', function(){
+ trait_table.columns.adjust();
+ });
+
function setUserColumnsDefWidths() {
var userColumnDef;
@@ -430,12 +448,12 @@
// If there is, set the width of this columnDef in px
if ( userColumnDef ) {
+ columnDef.sWidth = userColumnDef.width + 'px';
columnDef.width = userColumnDef.width + 'px';
}
});
-
}
@@ -473,11 +491,8 @@
// Save (or update) the settings in localStorage
localStorage.setItem(tableId, JSON.stringify(userColumnDefs));
-
}
- //trait_table.draw(); //ZS: This makes the table adjust its height properly on initial load
-
$('.toggle-vis').on( 'click', function (e) {
e.preventDefault();
--
cgit v1.2.3
From 8d727b8de708e48b298f42c673f8e902ac3df6a4 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 11 Mar 2021 22:57:49 +0000
Subject: Added a parameter to prevent columnDefs from being overwritten on
initial table generation + changed the default table width to 100%
---
wqflask/wqflask/templates/search_result_page.html | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 210cef30..973e9c23 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -125,8 +125,8 @@
{% endif %}
{% endif %}
-
-
+
+
Loading...
@@ -337,11 +337,13 @@
}{% endif %}
];
- loadDataTable();
+ loadDataTable(true);
- function loadDataTable(){
+ function loadDataTable(first_run=false){
- setUserColumnsDefWidths();
+ if (!first_run){
+ setUserColumnsDefWidths();
+ }
//ZS: Need to make sort by symbol, also need to make sure blank symbol fields at the bottom and symbols starting with numbers below letters
trait_table = $('#' + tableId).DataTable( {
--
cgit v1.2.3
From 814258b95436c5aabd76d932fde8386fea187e84 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 11 Mar 2021 23:08:43 +0000
Subject: Set scrollX in all cases so the adjustablee columns also work for
shorter results that don't use Scroller (<20 results)
---
wqflask/wqflask/templates/search_result_page.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 973e9c23..b2820496 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -405,9 +405,9 @@
"autoWidth": false,
"deferRender": true,
"bSortClasses": false,
+ "scrollX": true,
{% if trait_list|length > 20 %}
"scrollY": "500px",
- "scrollX": true,
"scroller": true,
"scrollCollapse": true,
{% else %}
--
cgit v1.2.3
From f421a7b319696bb57b9ea4c0a3ec94a32fa4aa65 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Wed, 24 Mar 2021 19:31:04 +0000
Subject: Use autoWidth on initial table load, though I'll change this to only
apply when certain fields (like Description) are below a certain width
Added some code tracking the change in width when a column's width is adjusted, so that the table_container width can be changed accordingly
---
wqflask/wqflask/templates/search_result_page.html | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index b2820496..22a22e68 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -126,7 +126,7 @@
{% endif %}
-
+
Loading...
@@ -174,6 +174,8 @@
var tableId = "trait_table";
+ var width_change = 0; //ZS: For storing the change in width so overall table width can be adjusted by that amount
+
columnDefs = [
{
'data': null,
@@ -196,7 +198,6 @@
'title': "Record",
'type': "natural-minus-na",
'data': null,
- 'width': "60px",
'targets': 2,
'render': function(data, type, row, meta) {
return '' + data.display_name + ''
@@ -232,7 +233,7 @@
{
'title': "
Mean
",
'type': "natural-minus-na",
- 'width': "30px",
+ 'width': "40px",
'data': "mean",
'targets': 6,
'orderSequence': [ "desc", "asc"]
@@ -346,7 +347,7 @@
}
//ZS: Need to make sort by symbol, also need to make sure blank symbol fields at the bottom and symbols starting with numbers below letters
- trait_table = $('#' + tableId).DataTable( {
+ table_settings = {
'drawCallback': function( settings ) {
$('#' + tableId + ' tr').off().on("click", function(event) {
if (event.target.type !== 'checkbox' && event.target.tagName.toLowerCase() !== 'a') {
@@ -402,7 +403,7 @@
"order": [[1, "asc" ]],
"sDom": "iti",
"destroy": true,
- "autoWidth": false,
+ "autoWidth": true,
"deferRender": true,
"bSortClasses": false,
"scrollX": true,
@@ -418,13 +419,22 @@
$('#' + tableId + '_wrapper .dataTables_scrollHead thead th').resizable({
handles: "e",
alsoResize: '#' + tableId + '_wrapper .dataTables_scrollHead table', //Not essential but makes the resizing smoother
+ resize: function( event, ui ) {
+ width_change = ui.size.width - ui.originalSize.width;
+ },
stop: function () {
saveColumnSettings();
loadDataTable();
}
});
},
- } );
+ }
+
+ if (!first_run){
+ table_settings['autoWidth'] = false;
+ $('#table_container').css("width", String($('#trait_table').width() + width_change) + "px"); //ZS : Change the container width by the change in width of the adjusted column, so the overall table size adjusts properly
+ }
+ trait_table = $('#' + tableId).DataTable(table_settings);
}
window.addEventListener('resize', function(){
@@ -488,7 +498,6 @@
});
}
-
});
// Save (or update) the settings in localStorage
--
cgit v1.2.3
From ed911b95571948c8c34ff5f3286f322cc9cfbbcf Mon Sep 17 00:00:00 2001
From: zsloan
Date: Wed, 24 Mar 2021 22:12:14 +0000
Subject: Store a dictionary of maximum widths for each field + create a
variable indicating if there are any wide columns (too wide to use
DataTables' 'autoWidth' setting)
---
wqflask/wqflask/search_results.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index f23c0582..c4d8d4ce 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -98,7 +98,6 @@ class SearchResultPage(object):
species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name)
# result_set represents the results for each search term; a search of
# "shh grin2b" would have two sets of results, one for each term
- logger.debug("self.results is:", pf(self.results))
for index, result in enumerate(self.results):
if not result:
@@ -164,6 +163,19 @@ class SearchResultPage(object):
trait_dict[key] = trait_dict[key].decode('utf-8')
trait_list.append(trait_dict)
+ self.max_widths = {}
+ for i, trait in enumerate(trait_list):
+ for key in trait.keys():
+ self.max_widths[key] = max(len(str(trait[key])), self.max_widths[key]) if key in self.max_widths else len(str(trait[key]))
+
+ self.wide_columns_exist = False
+ if this_trait.dataset.type == "Publish":
+ if (self.max_widths['display_name'] > 25 or self.max_widths['description'] > 100 or self.max_widths['authors']> 80):
+ self.wide_columns_exist = True
+ if this_trait.dataset.type == "ProbeSet":
+ if (self.max_widths['display_name'] > 25 or self.max_widths['symbol'] > 25 or self.max_widths['description'] > 100):
+ self.wide_columns_exist = True
+
self.trait_list = trait_list
if self.dataset.type == "ProbeSet":
--
cgit v1.2.3
From 52dcfe71be8cd86bfc19fa310fa3d65920d6f2af Mon Sep 17 00:00:00 2001
From: zsloan
Date: Wed, 24 Mar 2021 22:12:57 +0000
Subject: Added some default widths for situations where some wide columns
exist and autoWidth can't be used on initial load + changed the logic for how
to recalculate table width when a column is manually resized
---
wqflask/wqflask/templates/search_result_page.html | 55 +++++++++++++++++------
1 file changed, 42 insertions(+), 13 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html
index 22a22e68..8ecddc53 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -125,7 +125,7 @@
{% endif %}
{% endif %}
-