From 03342624fc5d50edd01804bcd4cc79ea2794e99d Mon Sep 17 00:00:00 2001 From: dm5wk Date: Thu, 15 May 2025 12:31:36 +0200 Subject: [PATCH] create toggle buttons automatically for columns --- band-plan.html | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/band-plan.html b/band-plan.html index 7172433..47bfd17 100644 --- a/band-plan.html +++ b/band-plan.html @@ -13,6 +13,9 @@ body>div { padding-bottom: 1em; } +div#togglebuttons>button { + margin: 0 0.1em; +} @@ -107,9 +110,17 @@ body>div { table.download("pdf", path.basename(document.getElementById('sel_plan').value, '.yml') + '.pdf', {}, download_range); }); //["band", "frequency", "bandwidth", "mode", "description"].forEach((col) => { - table.getColumns().forEach((col) => { - document.getElementById("toggle-" + col).addEventListener("click", () => { - table.toggleColumn(col); + table.on("tableBuilt", () => { + var div_togglebuttons = document.getElementById("togglebuttons"); + div_togglebuttons.innerHTML = "Toggle column:"; + table.getColumns().forEach((col) => { + let col_name = col.getField(); + let b = document.createElement("button"); + b.innerText = col_name; + b.addEventListener("click", () => { + table.toggleColumn(col_name); + }); + div_togglebuttons.appendChild(b); }); }); document.getElementById("error").innerText = ""; @@ -122,20 +133,14 @@ body>div {
-
-
- - - - - -
+
Use filter with "!" as "not".