Merge pull request #139 from fgimian/fix-date-sorting

Repaired sorting of date columns
This commit is contained in:
Daniele Sluijters
2015-05-10 11:51:29 +02:00
2 changed files with 46 additions and 9 deletions

View File

@@ -1,21 +1,38 @@
$ = jQuery
$ ->
$.tablesorter.addParser(
id: 'timestamp'
# Return false so this parser is not auto detected
is: (s) ->
false
# Normalize the timestamp to epoch for sorting
format: (s) ->
moment.utc(s).unix()
# The return value of our normalization function is an integer
type: 'numeric'
)
$('.nodes').tablesorter(
headers:
4:
sorter: false
sortList: [[1,0]]
headers:
2: sorter: 'timestamp'
3: sorter: 'timestamp'
4: sorter: false
sortList: [[1,0]]
)
$('.facts').tablesorter(
sortList: [[0,0]]
sortList: [[0,0]]
)
$('.dashboard').tablesorter(
headers:
3:
sorter: false
sortList: [[0, 1]]
headers:
2: sorter: 'timestamp'
3: sorter: false
sortList: [[0, 1]]
)
$('input.filter-table').parent('div').removeClass('hide')

View File

@@ -6,8 +6,25 @@
$(function() {});
$.tablesorter.addParser({
id: 'timestamp',
is: function(s) {
return false;
},
format: function(s) {
return moment.utc(s).unix();
},
type: 'numeric'
});
$('.nodes').tablesorter({
headers: {
2: {
sorter: 'timestamp'
},
3: {
sorter: 'timestamp'
},
4: {
sorter: false
}
@@ -21,6 +38,9 @@
$('.dashboard').tablesorter({
headers: {
2: {
sorter: 'timestamp'
},
3: {
sorter: false
}