Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort Chinese by Initials #763

Open
wants to merge 1 commit into
base: V3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/components/sorting/FooTable.Sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
var self = this, col = self.column;
self.ft.rows.array.sort(function (a, b) {
return col.direction == 'DESC'
? col.sorter(b.cells[col.index].sortValue, a.cells[col.index].sortValue)
: col.sorter(a.cells[col.index].sortValue, b.cells[col.index].sortValue);
? col.sorter(b.cells[col.index].sortValue, a.cells[col.index].sortValue,col.direction)
: col.sorter(a.cells[col.index].sortValue, b.cells[col.index].sortValue,col.direction);
});
},
/**
Expand Down
37 changes: 30 additions & 7 deletions src/js/components/sorting/extends/FooTable.Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,37 @@
* return 0;
* }
*/
F.Column.prototype.sorter = function(a, b){
if (typeof a === 'string') a = a.toLowerCase();
if (typeof b === 'string') b = b.toLowerCase();
if (a === b) return 0;
if (a < b) return -1;
return 1;
F.Column.prototype.sorter = function(a, b,c){
if (c == 'DESC') {
if (typeof a === 'string') a = a.toLowerCase().trim();
if (typeof b === 'string') b = b.toLowerCase().trim();
if (a.trim() === b.trim()) {
return 0;
}
if (a.trim() == "" || typeof a == undefined) {
return -1;
}
if (b.trim() == "" || typeof b == undefined)
{
return 1;
}
return a.trim().localeCompare(b.trim(),'zh');
} else {
if (typeof a === 'string') a = a.toLowerCase();
if (typeof b === 'string') b = b.toLowerCase();
if (a.trim() === b.trim()) {
return 0;
}
if (a.trim() == "" || typeof a == undefined) {
return 1;
}
if (b.trim() == "" || typeof b == undefined)
{
return -1;
}
return a.trim().localeCompare(b.trim(),'zh');
}
};

/**
* This is supplied either the cell value or jQuery object to parse. A value must be returned from this method and will be used during sorting operations.
* @param {(*|jQuery)} valueOrElement - The value or jQuery cell object.
Expand Down