Skip to content

Commit

Permalink
Add table sorting classes and css (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
billingb authored Nov 4, 2024
1 parent 7971066 commit aa0271d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@
margin: 9px 5px 9px 0px;
padding: 2px 5px;
}

.n2TableCanvas .nunaliit-sort-asc-1 a::after {
content: " \25bc";
}

.n2TableCanvas .nunaliit-sort-desc-1 a::after {
content: " \25b2";
}

20 changes: 20 additions & 0 deletions nunaliit2-js/src/main/js/nunaliit2/n2.canvasTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,26 @@ var TableCanvas = $n2.Class({
,direction: 1
});
};

const headerElements = $('th');
for(let i = 0; i < headerElements.length; i++){
$(headerElements[i]).removeClass();
}

//remove sort info
for(let i = 0; i < this.sortOrder.length; i++) {
const s = this.sortOrder[i];
const order = i+1
//add sort order info to th
const thElement = $(($(`a[data-sort-name=${s.name}]`).parent())[0])
if(s.direction > 0) {
thElement.addClass('nunaliit-sort-asc')
thElement.addClass(`nunaliit-sort-asc-${order}`)
} else {
thElement.addClass('nunaliit-sort-desc')
thElement.addClass(`nunaliit-sort-desc-${order}`)
}
}

this._sortRows(this.sortedRows);

Expand Down

0 comments on commit aa0271d

Please sign in to comment.