使用tablesorter对混合数据列进行排序 [英] Sort a mixed data column with tablesorter

查看:235
本文介绍了使用tablesorter对混合数据列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用此处的JQuery Tablesorter插件: http://www.tablesorter.com ,我遇到了包含日期和文本的列的问题。这是jsfiddle:

I'm currently using the JQuery Tablesorter plugin found here: http://www.tablesorter.com, and I'm having trouble with a column that contains both dates and text. Here's the jsfiddle:

http://jsfiddle.net / M3V4U / 1 /

如果单击名字字段标题,它将不会排序,因为里面有一个随机日期。我尝试强制文本排序但它不起作用。有什么想法吗?

If you click on the first name field title, it won't sort because there's a random date inside. I tried forcing a text sort but it wouldn't work. Anyone have any ideas?

推荐答案

看起来你正在尝试使用元数据设置分拣机类型

It looks like you're trying to set the sorter type using meta data

<th class="{sorter: 'text'}">first name</th>

但该演示中未加载元数据插件。因此,要么加载元数据插件,要么将分拣机类型添加到标题选项:

But the metadata plugin wasn't loaded in that demo. So either load the metadata plugin, or add the sorter type to the header option:

$("table").tablesorter({
  headers: {
    0: { sorter: "text" },
    4: { sorter: "percent" }
  }
});

这是更新了演示

这篇关于使用tablesorter对混合数据列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆