From cfa33d211372d40edcd35d2c0d74daf261fe6bf3 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 11 Mar 2025 16:50:04 -0500 Subject: Extract common DataTables into a reusable function. --- uploader/templates/phenotypes/view-dataset.html | 39 +++++++------------------ 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'uploader/templates') diff --git a/uploader/templates/phenotypes/view-dataset.html b/uploader/templates/phenotypes/view-dataset.html index 833ca12..f171483 100644 --- a/uploader/templates/phenotypes/view-dataset.html +++ b/uploader/templates/phenotypes/view-dataset.html @@ -96,21 +96,10 @@ dtAddCommonHandlers("#tbl-phenotypes-list"); var data = {{phenotypes | tojson}}; - 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: [ + var dtPhenotypesList = buildDataTable( + "#tbl-phenotypes-list", + data, + [ { data: function(pheno) { return ` { - 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); - } - } - }); - } - }); + { + // select: true, // extension is causing trouble. + rowId: function(pheno) { + return `${pheno.InbredSetCode}_${pheno.xref_id}`; + } + }); $("#btn-phenotypes-list-select-all").on("click", (event) => { dtPhenotypesList.rows().select(); -- cgit v1.2.3