如何按日期降序对数据表进行排序 [英] How to sort datatables with date in descending order
本文介绍了如何按日期降序对数据表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望显示基于数据表的记录,这些数据表基于我的日期&的其中一行进行默认排序时间以降序排列.请帮助我编辑该字段的jQuery结构
I wish to show the records using datatables with default ordering based on one of my rows with date & time in descending order. Please help me in editing the jquery structure for that
推荐答案
最简单的方法是在列的每个TD标签中的日期之前添加一个隐藏的时间戳,例如:
The simpliest way is to add a hidden timestamp before the date in every TD tag of the column, for example:
<td class="sorting_1">
<span style="display:none;">1547022615</span>09/01/2019 09:30
</td>
使用默认的字符串排序,时间戳将按您想要的方式对列进行排序,并且在浏览器中呈现时不会显示.
With the default string ordering, a timestamp would order the column the way you want and it will not be shown when rendered in the browser.
这篇关于如何按日期降序对数据表进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文