gpt4 book ai didi

javascript - jquery 表排序器 : addParser does not sort properly

转载 作者:行者123 更新时间:2023-11-28 09:20:52 25 4
gpt4 key购买 nike

我创建了一个表并使用 tablesorter 对它进行了排序。其中一列是字母和数字的混合(chr1、chr2、...、chr10、...、chrM)。我希望此列被排序,就好像它只是数字一样(从 1 到 22,然后按此顺序 X、Y 和 M)。我创建了自己的解析器,它可以工作,但只适用于某些行。然后,我找到另一个已正确排序的行 block ,后面跟着一些其他 block 。我不知道为什么会形成这个 block 。

代码是here 。也许使用较小的 table 就可以正常工作,因为我展示了一个大 table 。

提前致谢!

最佳答案

尝试这个解析器( demo )

$.tablesorter.addParser({
// set a unique id
id: 'chrom',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s) {
// format your data for normalization
return s.toLowerCase()
.replace('chr', '')
.replace('x', '97')
.replace('y', '98')
.replace('m', '99');
},
// set type, either numeric or text
type: 'numeric'
});

关于javascript - jquery 表排序器 : addParser does not sort properly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15003983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com