From 36a7408d2c5cf3b8b7ebb2168fd34415e37184d0 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 20 Jul 2022 20:54:11 +0000 Subject: Add drawCallback for highlighting selected rows to default tableSettings --- .../wqflask/static/new/javascript/create_datatable.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/create_datatable.js b/wqflask/wqflask/static/new/javascript/create_datatable.js index 2a895e18..fc9530a5 100644 --- a/wqflask/wqflask/static/new/javascript/create_datatable.js +++ b/wqflask/wqflask/static/new/javascript/create_datatable.js @@ -9,8 +9,22 @@ create_table = function(tableId, tableData, columnDefs, customSettings) { } tableSettings = { - 'data': tableData, - 'columns': columnDefs, + "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") + } + change_buttons() + }); + }, + "data": tableData, + "columns": columnDefs, "sDom": "iti", "destroy": true, "autoWidth": false, -- cgit v1.2.3