作者arianda (火鍋)
看板Ajax
標題Re: [ js ] jQuery的表格排序
時間Fri Dec 5 17:47:11 2008
※ 引述《arianda (火鍋)》之銘言:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.250.32.15
1F:→ fillano:他應該是用字串做比對的,可能取charAt一個一個比較排序吧 12/05 16:26
2F:→ fillano:嗯嗯,一些格子沒資料時,他會把數字當字串處理 12/05 16:32
3F:→ fillano:開發版本的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