create toggle buttons automatically for columns

This commit is contained in:
Wolfgang 2025-05-15 12:31:36 +02:00
parent 50e58f1628
commit 03342624fc

View file

@ -13,6 +13,9 @@
body>div { body>div {
padding-bottom: 1em; padding-bottom: 1em;
} }
div#togglebuttons>button {
margin: 0 0.1em;
}
</style> </style>
</head> </head>
@ -107,9 +110,17 @@ body>div {
table.download("pdf", path.basename(document.getElementById('sel_plan').value, '.yml') + '.pdf', {}, download_range); table.download("pdf", path.basename(document.getElementById('sel_plan').value, '.yml') + '.pdf', {}, download_range);
}); });
//["band", "frequency", "bandwidth", "mode", "description"].forEach((col) => { //["band", "frequency", "bandwidth", "mode", "description"].forEach((col) => {
table.getColumns().forEach((col) => { table.on("tableBuilt", () => {
document.getElementById("toggle-" + col).addEventListener("click", () => { var div_togglebuttons = document.getElementById("togglebuttons");
table.toggleColumn(col); div_togglebuttons.innerHTML = "<span>Toggle column:</span>";
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 = ""; document.getElementById("error").innerText = "";
@ -122,20 +133,14 @@ body>div {
</script> </script>
<div> <div>
<form name="selection"> <form name="selection">
<label>plan: <label>Plan:
<input name="plan" id="sel_plan" type="text" value="/plan-de.yml"> <input name="plan" id="sel_plan" type="text" value="/plan-de.yml">
</label> </label>
<button onclick="update_plan()">Change plan</button> <button onclick="update_plan()">Change plan</button>
<button id="print">Print plan</button> <button id="print">Print plan</button>
</form> </form>
</div> </div>
<div> <div id="togglebuttons"></div>
<button id="toggle-band">Toggle band</button>
<button id="toggle-frequency">Toggle frequency</button>
<button id="toggle-bandwidth">Toggle bandwidth</button>
<button id="toggle-mode">Toggle mode</button>
<button id="toggle-description">Toggle description</button>
</div>
<div> <div>
Use filter with "!" as "not". Use filter with "!" as "not".
</div> </div>