Re: [ js ] jQuery的表格排序

看板Ajax作者 (火鍋)時間17年前 (2008/12/05 17:47), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《arianda (火鍋)》之銘言: -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.250.32.15

12/05 16:26,
他應該是用字串做比對的,可能取charAt一個一個比較排序吧
12/05 16:26

12/05 16:32,
嗯嗯,一些格子沒資料時,他會把數字當字串處理
12/05 16:32

12/05 16:48,
開發版本的js檔案有例子,可以指定某個欄位用哪個parser
12/05 16:48
謝謝提醒我有Parser可以用, 改成下面的就正常了 $.tablesorter.addParser({ // set a unique id id: 'numberic', is: function(s) { // return false so this parser is not auto detected return false; }, format: function(s) { // format your data for normalization // 回傳為數值 return parseInt(s) }, // set type, either numeric or text type: 'numeric' }); $(document).ready(function(){ $("#myTable").tablesorter({ headers: { 7: {sorter:'numberic'}, //7,6欄位都使用這Parser 6: {sorter:'numberic'} //保險是全部數值欄位都要設定 } }); } ); -- 海綿寶寶, 不要講話!派大星! 我覺得有人在盯著我們看... 你會害我們被發現! JUNU -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.250.32.15
文章代碼(AID): #19EFYXH3 (Ajax)
文章代碼(AID): #19EFYXH3 (Ajax)