我正在使用 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/