From b1629deb7822b165dbb42de4662e9ab968170e95 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 22 Feb 2022 22:02:09 +0000 Subject: Add JS initializing DataTables --- .../static/new/javascript/partial_correlations.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/partial_correlations.js b/wqflask/wqflask/static/new/javascript/partial_correlations.js index b3a89c5e..030b63f2 100644 --- a/wqflask/wqflask/static/new/javascript/partial_correlations.js +++ b/wqflask/wqflask/static/new/javascript/partial_correlations.js @@ -249,6 +249,8 @@ function display_partial_corr_results(data, status, xhr) { data["results"]["control_traits"], data["results"]["correlations"], data["results"]["method"]); + + initializePcorrTable(data["results"]["dataset_type"]); } function display_partial_corr_error(xhr, status, error) { @@ -285,6 +287,40 @@ function send_data_and_process_results( }); } +function initializePcorrTable(dataType){ + tableId = "part-corr-results-" + dataType.toLowerCase(); + if (dataType == "Publish") { + orderCol = 7; + } else if (dataType == "ProbeSet") { + orderCol = 11; + } else { + orderCol = 6; + } + + $('#' + tableId).dataTable( { + 'drawCallback': function( settings ) { + $('#' + tableId + ' tr').off().on("click", function(event) { + if (event.target.type !== 'checkbox' && event.target.tagName.toLowerCase() !== 'a') { + var obj =$(this).find('input'); + obj.prop('checked', !obj.is(':checked')); + } + if ($(this).hasClass("selected") && event.target.tagName.toLowerCase() !== 'a'){ + $(this).removeClass("selected") + } else if (event.target.tagName.toLowerCase() !== 'a') { + $(this).addClass("selected") + } + }); + }, + "order": [[orderCol, "asc" ]], + "sDom": "itir", + "iDisplayLength": -1, + "autoWidth": false, + "bDeferRender": true, + "bSortClasses": false, + "paging": false + } ); +} + $("#partial-correlations-form").submit(function(e) { e.preventDefault(); }); -- cgit v1.2.3