作者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