問題を解決する方法を見つけました。最小値を返すフィルターを作成します。したがって、並べ替えが昇順の場合はダッシュが下に表示され、並べ替えが降順の場合は上に表示されます。私のソートがdescの場合、ダッシュが一番上にある方が論理的だと思います。なぜなら、0を入れた場合と同じだからです;)
だからそれは私のフィルターです:
$.tablesorter.addParser({
id: "dashSorter",
format: function(s) {
return ($.trim(s) === '-') ? Number.MIN_VALUE : $.tablesorter.formatFloat(s.replace(/[,:]/g, ""));
},
type: "numeric"
});
私は正規表現に「:」を入れました.HH:mm:ssの形式で時間があり(削除できます)、私のスクリプトは私のテーブルをソートします:
$("table[name=table_sorter]").tablesorter({
// initialize zebra striping and filter widgets
widgets : ['zebra', 'filter'],
headers : {
1 : {sorter:'dashSorter'},
2 : {sorter:'dashSorter'},
3 : {sorter:'dashSorter'}
},
widgetOptions : {
// css class applied to the table row containing the filters & the inputs within that row
filter_cssFilter : 'tablesorter-filter',
// If there are child rows in the table (rows with class name from "cssChildRow" option)
// and this option is true and a match is found anywhere in the child row, then it will make that row
// visible; default is false
filter_childRows : false,
// if true, filters are collapsed initially, but can be revealed by hovering over the grey bar immediately
// below the header row. Additionally, tabbing through the document will open the filter row when an input gets focus
filter_hideFilters : false,
// Set this option to false to make the searches case sensitive
filter_ignoreCase : true,
// jQuery selector string of an element used to reset the filters
filter_reset : '.reset',
// Delay in milliseconds before the filter widget starts searching; This option prevents searching for
// every character while typing and should make searching large tables faster.
filter_searchDelay : 300,
// Set this option to true to use the filter to find text from the start of the column
// So typing in "a" will find "albert" but not "frank", both have a's; default is false
filter_startsWith : false
}
});
人々を助けて、すぐにお会いできることを願っています;)