3

jQuery Tablesorter 2.0 (http://tablesorter.com/docs/) を使用しています。数字の並べ替えは正常に機能していますが、追加するとすぐに

number_format($count);

私のコードでは、並べ替えが機能しなくなりました。次のように並べ替えます。

810,208 -> 7,671,897 -> 2,329,439

それ以外の

7,671,897 -> 2,329,439 -> 810,208

これを修正する方法はありますか?読みやすくするために、カンマ区切りの番号が必要です。ありがとう

4

1 に答える 1

11

http://www.christianmontoya.com/2008/11/14/extending-jquery-tablesorter-to-support-comma-delimited-numbers/

jQuery.tablesorter.addParser({
  id: "fancyNumber",
  is: function(s) {
    return /^[0-9]?[0-9,\.]*$/.test(s);
  },
  format: function(s) {
    return jQuery.tablesorter.formatFloat( s.replace(/,/g,'') );
  },
  type: "numeric"
});
于 2012-06-11T17:38:17.237 に答える