automatically add all columns

This commit is contained in:
Wolfgang 2024-05-23 18:00:11 +02:00
parent 37e847990f
commit e98837082e

View file

@ -88,31 +88,18 @@ div#togglebuttons>button {
}
}
function debug_tdata(s, tdata) {
if (tdata.length > 0) {
console.log(s + " " + tdata.length + " " + tdata[tdata.length - 1].frequency + " " + tdata[tdata.length - 1].power_a);
//console.log(s + " " + tdata.length);
//tdata.forEach((t) => {
// console.log(s + " " + t.frequency);
//});
}
}
function update_table(bands, additions) {
var tdata = [];
bands.forEach((band) => {
band.parts.forEach((part) => {
let p = {
"band": band.band,
"frequency": typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end,
"mode": band.mode,
//"band_start": band.start,
//"band_end": band.end,
"bandwidth": band.bandwidth,
"description": part.description,
"frequency": typeof part.at !== "undefined" ? part.at : part.start + '\u2013' + part.end,
//"at": part.at,
//"start": part.start,
//"end": part.end,
};
let parts_already_added = false;
additions.forEach((add) => {
@ -170,21 +157,26 @@ div#togglebuttons>button {
],
selectableRows: true,
data: tdata,
columns: [
// eslint-disable-next-line no-unused-vars
{title: "band", field: "band", headerFilter: "input", sorter: function(a, b, aRow, bRow, column, dir, sorterParams){
autoColumns:"full",
// add filter for all columns
autoColumnsDefinitions: function(definitions){
definitions.forEach((column) => {
if (column.field == "band") {
column.sorter = function(a, b, aRow, bRow, column, dir, sorterParams) {
return parseFloat(new Measures().from(a).to('m')) - parseFloat(new Measures().from(b).to('m'));
}},
{title: "frequency/kHz", field: "frequency", sorter: "number", headerFilter: "input", headerFilterFunc: filter_with_not},
{title: "bandwidth/Hz", field: "bandwidth", headerFilter: "input", headerFilterFunc: filter_with_not},
{title: "mode", field: "mode", headerFilter: "input", headerFilterFunc: filter_with_not},
//{title: "band_start", field: "band_start", headerFilter: "input"},
//{title: "band_end", field: "band_end", headerFilter: "input"},
{title: "description", field: "description", headerFilter: "input", headerFilterFunc: filter_with_not},
{title: "power_a", field: "power_a", headerFilter: "input", headerFilterFunc: filter_with_not},
{title: "power_e", field: "power_e", headerFilter: "input", headerFilterFunc: filter_with_not},
{title: "power_n", field: "power_n", headerFilter: "input", headerFilterFunc: filter_with_not},
],
}
}
if (column.field == "frequency") {
column.sorter = "number";
}
column.headerFilter = "input";
column.headerFilterFunc = filter_with_not;
});
return definitions;
},
});
document.getElementById("download").addEventListener("click", () => {