我正在使用Tablesorter来显示数据,但是它是以升序显示的,我想将其显示为降序,因此表的最新添加总是在顶部。
这是我的代码:

            // *** sort options
            headers          : {},         // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
            ignoreCase       : true,       // ignore case while sorting
            sortForce        : null,       // column(s) first sorted; always applied
            sortList         : [],         // Initial sort order; applied initially; updated when manually sorted
            sortAppend       : null,       // column(s) sorted last; always applied
            sortStable       : false,      // when sorting two rows with exactly the same content, the original sort order is maintained

            sortInitialOrder : 'desc',      // sort direction on first click
            sortLocaleCompare: false,      // replace equivalent character (accented characters)
            sortReset        : false,      // third click on the header will reset column to default - unsorted
            sortRestart      : false,      // restart sort to "sortInitialOrder" when clicking on previously unsorted columns


真的不确定要编辑/更改的内容,因此,任何建议都将不胜感激。

注意

我删除了原始代码,因为它实际上与我要实现的目标无关。
这是我认为需要编辑的js的排序选项部分。

最佳答案

我找到了解决方案,打开jquerytablesorter js,然后进行如下编辑:
-sortList:[[0,1]]-0表示第一列,1表示下降。我在以下位置找到了信息:mottie.github.io/tablesorter/docs/#sortlist

关于javascript - 将Tablesorter设置为降序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26051237/

10-15 03:04