表排序问题
我正在尝试使用可排序的 jQuery 插件,虽然它工作得很好,但我注意到,除了以字母或数字开头的其他值之外,当我在列中缺少值时,由于某种原因,空单元格出现在DESC 排序中的中间位置,而不是按预期下降。
这是演示。请对最后一列进行排序。
我需要修改什么来解决这个问题?
I am trying to use sortable, a jQuery plugin and while it works great I noticed that when I have a missing value in a column in addition to other values that start either with a letter or a number, for some reason the empty cell appears in the middle in DESC sort, instead of dropping down as expected.
Here's the DEMO. Please sort last column.
What do I need to modify to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
似乎是一个错误,它无法正确对数字和字母数字的混合大小写进行排序。例如,如果您输入“zzz”而不是空格,它仍然保留在中间。
解决方法如下:
更新以修复其他列中的排序
http://jsfiddle.net/HvKmP/31/
Seems like a bug that it doesn't sort mixed case of numbers and alphanumeric ones properly. E.g. if you put "zzz" instead of space, it still stays in middle.
Here's a workaround:
Updated to fix sort in other columns
http://jsfiddle.net/HvKmP/31/
更新版本
The updated version
http://jsfiddle.net/HvKmP/19/
有两件事需要注意。首先,您的最后一列有“s22”和“a45”。删除字母修复了排序。其次,发生的情况是排序器读取第一行并看到一个数字,并假设其余部分也将是数字。数字的排序是对数字进行排序,然后将非数字值保留为未排序。
http://jsfiddle.net/HvKmP/19/
There are two things to note. First, your final column had 's22' and 'a45'. Removing the letters fixed the sorting. Secondly, what's hapenning is that the sorter reads the first row and see's a number and is assuming the rest will be numerical too. The sorting for numbers is sorting the numbers, then leaving the non-numeric values as unsorted.
实际上问题出在你使用的javascript中,没有排序,td包含数字作为第一个字母,尝试改变它,你会看到它工作。
Actually the problem is in the javascript you are using is not sorting is the td's contain numbers as the first letter, try changing this and you will see it working.