diff options
author | zsloan | 2020-12-03 13:46:18 -0600 |
---|---|---|
committer | zsloan | 2020-12-03 13:46:18 -0600 |
commit | fabb29b6f47c11d3a1eeeb4cb94c8362e282dca3 (patch) | |
tree | 9058fd8243d96fbeb9d3a5ce1997ffe0346e6d15 /wqflask | |
parent | 5506ac96077db794c945cc1325300dead8073eea (diff) | |
download | genenetwork2-fabb29b6f47c11d3a1eeeb4cb94c8362e282dca3.tar.gz |
Converted the submit_traits_to_export_or_bnw function to using DataTables API, since the JQuery it was previously using didn't work with Scroller
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/static/new/javascript/search_results.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 86660126..27d89867 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -157,18 +157,23 @@ $(function() { }); table_dict['headers'] = headers; - rows = []; - trait_table.find('tbody tr').each(function (i, tr) { - if (trait_table.find('input[name="searchResult"]:checked').length > 0) { - if ($(this).find('input[name="searchResult"]').is(':checked')){ - rows.push($(this).find('input[name="searchResult"]:checked').val()) - } - } - else { - rows.push($(this).find('input[name="searchResult"]').val()) + selected_rows = []; + all_rows = []; //ZS: If no rows are checked, export all + table_api = $('#' + table_name).DataTable(); + check_cells = table_api.column(0).nodes().to$(); + for (let i = 0; i < check_cells.length; i++) { + this_node = check_cells[i].childNodes[0]; + all_rows.push(this_node.value) + if (this_node.checked){ + selected_rows.push(this_node.value) } - }); - table_dict['rows'] = rows; + } + + if (selected_rows.length > 0){ + table_dict['rows'] = selected_rows; + } else { + table_dict['rows'] = all_rows; + } json_table_dict = JSON.stringify(table_dict); $('input[name=export_data]').val(json_table_dict); |