#82 sort order fix for datatable

use ‘asc’ as default order when clicking on another sortable column
header
This commit is contained in:
Denys Vuika 2016-05-20 11:07:20 +01:00
parent ceed1a0a48
commit 30558fb571

View File

@ -90,7 +90,10 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
onColumnHeaderClick(column: DataColumn) { onColumnHeaderClick(column: DataColumn) {
if (column && column.sortable) { if (column && column.sortable) {
let current = this.data.getSorting(); let current = this.data.getSorting();
let newDirection = current.direction === 'asc' ? 'desc' : 'asc'; let newDirection = 'asc';
if (column.key === current.key) {
newDirection = current.direction === 'asc' ? 'desc' : 'asc';
}
this.data.setSorting(new DataSorting(column.key, newDirection)); this.data.setSorting(new DataSorting(column.key, newDirection));
} }
} }