javascript - 使用 StupidTable JS 和日期列进行排序

标签 javascript php jquery sorting

我正在使用 StupidTable JS 对表格列进行排序。效果很好。然而,我的大部分专栏都以

排序
data-sort='string'

现在我有一个 DATE 列需要排序。不知道该怎么做。信息来自数据库,所以我相信我需要一些功能。每个日期的格式是

dd-Mon-yyyy ex: 12-MAY-2015 or 25-JUL-2014

??

最佳答案

如果您可以控制 HTML 的呈现,则可以在显示漂亮日期的同时对时间戳进行排序。

https://github.com/joequery/Stupid-Table-Plugin#data-with-multiple-representationspredefined-order

否则,您将需要创建自定义排序函数。

<table>
  <thead>
    <tr>
      <th data-sort="string">Name</th>
      <th data-sort="int">Birthday</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Joe McCullough</td>
      <td data-sort-value="672537600">April 25, 1991</td>
    </tr>
    <tr>
      <td>Clint Dempsey</td>
      <td data-sort-value="416016000">March 9, 1983</td>
    </tr>
    ...

关于javascript - 使用 StupidTable JS 和日期列进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32314052/

相关文章:

javascript - GridStack 如何禁用移动或拖动网格小部件

javascript - Ajax 客户端控件 - 内存泄漏

php - 删除换行符和空格

javascript - 是否有具有 outlook.com (metro) "look and feel"和功能的 javascript 控件库?

PHP 不回显所有 MySQL 行

php - 尝试在 WordPress 中使用 DFP 广告管理系统定位 - 需要有关问题的建议 -

javascript - 具有批量编辑网格的 Telerik MVC 网站可防止窗口关闭时未保存的更改

jquery - 在 Div 中拖动 CSS 旋转图像

javascript - 弹出窗口 jQ​​uery

javascript - White Space with Isotope 插件扩展框时,怎么办?