diff --git a/src/js/components/sorting/FooTable.Sorting.js b/src/js/components/sorting/FooTable.Sorting.js index 6ffdfa65..924e5fb0 100644 --- a/src/js/components/sorting/FooTable.Sorting.js +++ b/src/js/components/sorting/FooTable.Sorting.js @@ -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); }); }, /** diff --git a/src/js/components/sorting/extends/FooTable.Column.js b/src/js/components/sorting/extends/FooTable.Column.js index fb8b215a..6a36392f 100644 --- a/src/js/components/sorting/extends/FooTable.Column.js +++ b/src/js/components/sorting/extends/FooTable.Column.js @@ -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.