about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-03-10 17:28:35 -0500
committerFrederick Muriuki Muriithi2025-03-10 17:28:35 -0500
commitef71af77671669531bbc07c7363511117b7d13e9 (patch)
tree8b01270826280fd6a5ac3ace8ebc571274a5f22d
parent973ee9c3ff7ee8ad730ab0abfd9eeff97bf0f261 (diff)
downloadgn-uploader-ef71af77671669531bbc07c7363511117b7d13e9.tar.gz
Enable selecting and deselecting ALL rows.
-rw-r--r--uploader/templates/phenotypes/view-dataset.html51
1 files changed, 41 insertions, 10 deletions
diff --git a/uploader/templates/phenotypes/view-dataset.html b/uploader/templates/phenotypes/view-dataset.html
index 38a4d11..833ca12 100644
--- a/uploader/templates/phenotypes/view-dataset.html
+++ b/uploader/templates/phenotypes/view-dataset.html
@@ -96,16 +96,20 @@
       dtAddCommonHandlers("#tbl-phenotypes-list");
 
       var data = {{phenotypes | tojson}};
-      $("#tbl-phenotypes-list").DataTable({
-          responsive: true,
-          lengthMenu: [10, 25, 50, 100, 1000, data.length],
-          language: {
-              processing: "Processing results… Please wait.",
-              loadingRecord: "Loading phenotypes — Please wait.",
-              info: "_START_ to _END_ of _TOTAL_ phenotypes",
-              lengthMenu: "Show _MENU_ phenotypes",
+      var dtPhenotypesList = $("#tbl-phenotypes-list").DataTable({
+          select: true,
+          select: {
+              selector: "td:first-child.chk-row-select"
           },
+          scroller: true,
+          sDom: "iti",
+          scrollY: "100vh",
+          scrollCollapse: true,
+          responsive: true,
           data: data,
+          rowId: function(pheno) {
+              return `${pheno.InbredSetCode}_${pheno.xref_id}`;
+          },
           columns: [
               {
                   data: function(pheno) {
@@ -117,7 +121,7 @@
               },
               {data: "sequence_number"},
               {
-                  data: function(pheno) {
+                  data: function(pheno, type, set, meta) {
                       var spcs_id = {{species.SpeciesId}};
                       var pop_id = {{population.Id}};
                       var dtst_id = {{dataset.Id}};
@@ -137,7 +141,34 @@
                               pheno.Pre_publication_description);
                   }
               }
-          ]
+          ],
+          drawCallback: function(settings) {
+              $(this[0]).find("tbody tr").each((idx, row) => {
+                  var arow = $(row);
+                  var checkboxOrRadio = arow.find(".chk-row-select");
+                  if (checkboxOrRadio) {
+                      if (arow.hasClass("selected")) {
+                          checkboxOrRadio.prop("checked", true);
+                      } else {
+                          checkboxOrRadio.prop("checked", false);
+                      }
+                  }
+              });
+          }
+      });
+
+      $("#btn-phenotypes-list-select-all").on("click", (event) => {
+          dtPhenotypesList.rows().select();
+          dtPhenotypesList.rows().nodes().each((node, idx) => {
+              $(node).find(".chk-row-select").prop("checked", true);
+          });
+      });
+
+      $("#btn-phenotypes-list-deselect-all").on("click", (event) => {
+          dtPhenotypesList.rows().deselect();
+          dtPhenotypesList.rows().nodes().each((node, idx) => {
+              $(node).find(".chk-row-select").prop("checked", false);
+          });
       });
   });
 </script>