about summary refs log tree commit diff
path: root/uploader/static/js
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-03-12 12:47:18 -0500
committerFrederick Muriuki Muriithi2025-03-12 12:47:18 -0500
commit43118074beaaebd8e3ed0bc134ef6edf918abd41 (patch)
treec33e50a2d43a1b053392da49cbc2eaff801bb184 /uploader/static/js
parent93890cefb7ee7cf098469fddb2179cdb0b07b124 (diff)
downloadgn-uploader-43118074beaaebd8e3ed0bc134ef6edf918abd41.tar.gz
Update default DataTables settings for Select and Scroller extensions.
Diffstat (limited to 'uploader/static/js')
-rw-r--r--uploader/static/js/datatables.js27
1 files changed, 22 insertions, 5 deletions
diff --git a/uploader/static/js/datatables.js b/uploader/static/js/datatables.js
index 9782a60..f93fdee 100644
--- a/uploader/static/js/datatables.js
+++ b/uploader/static/js/datatables.js
@@ -77,19 +77,26 @@ var defaultLengthMenu = (data) => {
 var buildDataTable = (tableId, data = [], columns = [], userSettings = {}) => {
     var defaultSettings = {
         responsive: true,
+        layout: {
+            topStart: null,
+            topEnd: null,
+            bottomStart: null,
+            bottomEnd: null,
+        },
+        select: true,
         /* == Scroller settings == */
         scroller: true,
         paging: true, // MUST be true for scroller to work
-        sDom: "iti",
-        scrollY: "100vh",
+        scrollY: "750px",
         scrollCollapse: true,
+        deferRender: true,
         /* == END: Scroller settings == */
         lengthMenu: defaultLengthMenu(data),
         language: {
             processing: "Processing… Please wait.",
-            loadingRecords: "Loading population — Please wait.",
-            lengthMenu: "Show _MENU_ populations",
-            info: "Showing _START_ to _END_ of _TOTAL_ populations"
+            loadingRecords: "Loading table data… Please wait.",
+            lengthMenu: "",
+            info: ""
         },
         data: data,
         columns: columns,
@@ -111,5 +118,15 @@ var buildDataTable = (tableId, data = [], columns = [], userSettings = {}) => {
         ...defaultSettings,
         ...userSettings
     });
+    theDataTable.on("select", (event, datatable, type, cell, originalEvent) => {
+        datatable.rows({selected: true}).nodes().each((node, index) => {
+            $(node).find(".chk-row-select").prop("checked", true)
+        });
+    });
+    theDataTable.on("deselect", (event, datatable, type, cell, originalEvent) => {
+        datatable.rows({selected: false}).nodes().each((node, index) => {
+            $(node).find(".chk-row-select").prop("checked", false)
+        });
+    });
     return theDataTable;
 };