diff options
author | zsloan | 2015-05-13 17:10:47 +0000 |
---|---|---|
committer | zsloan | 2015-05-13 17:10:47 +0000 |
commit | 960b4237249f6b7b914404dc312d77ed37049fe3 (patch) | |
tree | f9fd53ecb5bf3d7096e774d661cbf57084c65be7 /wqflask | |
parent | 8fa315467f70a4b14e40ed2f5d4adce15ef24bc6 (diff) | |
download | genenetwork2-960b4237249f6b7b914404dc312d77ed37049fe3.tar.gz |
Improved sorting for columns with N/A or missing values
Diffstat (limited to 'wqflask')
-rwxr-xr-x | wqflask/wqflask/templates/search_result_page.html | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index c7c2a62f..ebae41af 100755 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -119,22 +119,37 @@ <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> <script type="text/javascript" charset="utf-8"> + + console.log("TESTING:", parseFloat("TESTING")) + function getValue(x) { if (x.indexOf('input') >= 0) { if ($(x).val() == 'x') { - return 0 + return 0; } else { return parseFloat($(x).val()); } } + else if (isNaN(x)) { + return x; + } return parseFloat(x); } jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { var x = getValue(a); - var y = getValue(b); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + var y = getValue(b); + + if (x == 'N/A' || x == '') { + return 1; + } + else if (y == 'N/A' || y == '') { + return -1; + } + else { + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + } }; jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { @@ -164,21 +179,12 @@ "sWidth": "35%" }, { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" }, + { "sType": "natural" }, { "sType": "natural", "sWidth": "12%" }, { "sType": "natural", "sWidth": "15%" }, - { "sType": "cust-txt" } - ], - "columns": [ - { "width": "50%" }, - null, - null, - null, - null, - null, - null + { "sType": "natural" } ], "sDom": "tir", "iDisplayLength": -1, @@ -187,7 +193,6 @@ "bDeferRender": true, "bSortClasses": false } ); - {% elif dataset.type == 'Publish' %} $('#trait_table').dataTable( { //"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>", @@ -200,16 +205,8 @@ "sWidth": "20%" }, { "sType": "natural" }, { "sType": "cust-txt" }, - { "sType": "natural" } - ], - "columns": [ - { "width": "50%" }, - null, - null, - null, - null, - null, - null + { "sType": "natural" }, + { "sType": "cust-txt" } ], "sDom": "tir", "iDisplayLength": -1, |