Sorting issue
There is a issue in sorting when navigating to descending. The issue is in the file
ng2-table/components/table/ng-table-sorting.directive.ts
line 28: this.column.sort = '';
It works when its changed to this.column.sort = 'asc';
Can this fix be added soon.
Sasi
I don't think they see this as an issue. As far as I understood, When it's ascending and you click the column, it changes to descending. When it's descending and you click it, it returns to the default order of the list...(even if the default it's no order...). And then you click again, it changes to ascending again... I think it's actually 3 different status: 1. No order/default order as it is in the array, 2. ascending 3. descending. I'm not saying this is good though... I actually changed my code as you suggested, so this "No order" status doesn't exists anymore...
Many Thanks. Can you please push this change to the master branch?
@raquelleira could you please check out #335? Is it possible to change the sorting so that step (1) is disabled completely?
@raquelleira How to disable the 3rd click in ng2-table/demo/components/table/table-demo.ts file? Plese suggest
You can customize component as below.
ng2-table/components/table/ng-table-sorting.directive.js line:17
Then you can see these code
NgTableSortingDirective.prototype.onToggleSort = function (event) {
if (event) {
event.preventDefault();
}
if (this.ngTableSorting && this.column && this.column.sort !== false) {
switch (this.column.sort) {
case 'asc':
this.column.sort = 'desc';
break;
case 'desc':
this.column.sort = '';
break;
default:
this.column.sort = 'asc';
break;
}
this.sortChanged.emit(this.column);
}
};
This is code for switching sorting mode. If you change this as below then you can use only two methods.
NgTableSortingDirective.prototype.onToggleSort = function (event) {
if (event) {
event.preventDefault();
}
if (this.ngTableSorting && this.column && this.column.sort !== false) {
switch (this.column.sort) {
case 'asc':
this.column.sort = 'desc';
break;
case 'desc':
this.column.sort = 'asc';
break;
default:
this.column.sort = 'asc';
break;
}
this.sortChanged.emit(this.column);
}
};
You can fort repository and use component as freely :)
@webcat12345 You are awesome!!!
@webcat12345 Is it possible to override this functionality in the file table-demo.ts of ng2-table/demo/components/table/?? I want to have only 2 way sorting in the implementation level and this is in module level. I mean if someone wants to implement my project, he will do an "npm install ng2-table" and he has to change the below code manually case 'desc': this.column.sort = 'asc'; break; So is it possible to customize this in our own code which implements ng2-table?
Thanks
@webcat12345 Any solution for the above problem?
Currently there is no other way. But you can fork this repository and can make changes to component