every click on a column title changes the sort order

This commit is contained in:
tracer 2022-10-25 18:25:38 +02:00
parent ce798e3b65
commit 8e0a2ff6e8

View File

@ -80,6 +80,15 @@ function deleteAddress(id) {
function sortBy(column) {
console.log("sortby: " + column)
// switch direction on every call
let currentSortOrder = document.getElementById(column + '_sort')
let sortOrder = 0
if (currentSortOrder.innerHTML === 'asc') {
currentSortOrder.innerHTML = 'desc'
} else {
currentSortOrder.innerHTML = 'asc'
}
const table = document.getElementById('address_table');
let dirty = true;
// loop until clean
@ -102,7 +111,15 @@ function sortBy(column) {
console.log(valueX, valueY)
// mind asc & desc
let sortOrder = 1
let currentSortOrder = document.getElementById(column + '_sort')
let sortOrder = 0
if (currentSortOrder.innerHTML === 'asc') {
sortOrder = 1
} else {
sortOrder = -1
}
console.log("cs", currentSortOrder.innerHTML)
console.log(valueX.localeCompare(valueY))
if (valueX.localeCompare(valueY) === sortOrder) {