Add units and make sortable

This commit is contained in:
phl0
2025-01-14 10:03:53 +01:00
parent 091acb8b36
commit 682f606d3f
3 changed files with 24 additions and 12 deletions

View File

@@ -736,16 +736,16 @@ $options = json_decode($options);
echo '<th class="distance-column-sort">' . __("Distance") . '</th>';
} ?>
<?php if (($options->antennaazimuth->show ?? "true") == "true") {
echo '<th data-bs-toggle="tooltip" data-bs-placement="top" title="' . __("Antenna azimuth") . '">' . __("Ant az") . '</th>';
echo '<th class="antennaazimuth-column-sort" data-bs-toggle="tooltip" data-bs-placement="top" title="' . __("Antenna azimuth") . '">' . __("Ant az") . '</th>';
} ?>
<?php if (($options->antennaelevation->show ?? "true") == "true") {
echo '<th data-bs-toggle="tooltip" data-bs-placement="top" title="' .__("Antenna elevation") .'">' . __("Ant el") . '</th>';
echo '<th class="antennaelevation-column-sort" data-bs-toggle="tooltip" data-bs-placement="top" title="' .__("Antenna elevation") .'">' . __("Ant el") . '</th>';
} ?>
<?php if (($options->profilename->show ?? "true") == "true") {
echo '<th>' . __("Profile name") . '</th>';
} ?>
<?php if (($options->stationpower->show ?? "true") == "true") {
echo '<th>' . __("Station power") . '</th>';
echo '<th class="stationpower-column-sort">' . __("Station power") . '</th>';
} ?>
</tr>
</thead>

View File

@@ -169,11 +169,23 @@ function loadQSOTable(rows) {
url: getDataTablesLanguageUrl(),
},
"columnDefs": [
{
"targets": $(".distance-column-sort").index(),
"type": "distance", // use the custom sort type from the previous example
}
]
{
"targets": $(".distance-column-sort").index(),
"type": "numbersort", // use the custom sort type from the previous example
},
{
"targets": $(".antennaazimuth-column-sort").index(),
"type": "numbersort",
},
{
"targets": $(".antennaelevation-column-sort").index(),
"type": "numbersort",
},
{
"targets": $(".stationpower-column-sort").index(),
"type": "numbersort",
},
]
// colReorder: {
// order: [0, 2,1,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18]
// // order: [0, customsortorder]
@@ -337,7 +349,7 @@ function loadQSOTable(rows) {
$('[data-bs-toggle="tooltip"]').tooltip();
}
$.fn.dataTable.ext.type.order['distance-pre'] = function(data) {
$.fn.dataTable.ext.type.order['numbersort-pre'] = function(data) {
var num = parseFloat(data);
return isNaN(num) ? 0 : num;
};

View File

@@ -1224,11 +1224,11 @@ class QSO
'sig' => $this->getFormattedSig(),
'continent' => $this->continent,
'profilename' => $this->profilename,
'stationpower' => $this->stationpower,
'stationpower' => empty($this->stationpower) ? null : $this->stationpower.' W',
'distance' => $this->getFormattedDistance(),
'region' => $this->region,
'antennaelevation' => $this->antennaelevation,
'antennaazimuth' => $this->antennaazimuth
'antennaelevation' => empty($this->antennaelevation) ? null : $this->antennaelevation.'°',
'antennaazimuth' => empty($this->antennaazimuth) ? null : $this->antennaazimuth.'°'
];
}