简体   繁体   English

tinytable如何按降序排序表而不是升序

[英]tinytable how to sort table in descending order rather then ascending

I'm using the tinytable table sorting script. 我正在使用tinytable表排序脚本。

See example at http://sandbox.scriptiny.com/table-sorter/index.html . 请参阅http://sandbox.scriptiny.com/table-sorter/index.html上的示例。

It's a very basic script about 2.5kb. 这是一个约2.5kb的非常基本的脚本。 To use the script we do sorter.init("table",1); 要使用该脚本,我们进行sorter.init("table",1); where table is the table id and 1 is the initial column to be sorted. 其中table是表id,1是要排序的初始列。 This works great but initial column is sorted in asc order. 这很好,但初始列按asc顺序排序。 There is not an option to make it initially sort in descending order. 没有选项可以使它最初按降序排序。 I tried to look into the js file but couldn't figure it out. 我试着查看js文件,但无法弄明白。 What do I need to do to make it the initial column sort in desc order? 我需要做什么才能使它成为desc顺序的初始列排序?

I am working on this and to sort the table in a descending order just change the sort direction to be -1 我正在研究这个并按降序对表进行排序只需将排序方向更改为-1

    sortcolumn:0, // sort column 1
    sortdir:-1, // sort direction either 1 asc or -1 desc

One line of the script reads return g>h?1:(g<h?-1:0) . 脚本的一行读取return g>h?1:(g<h?-1:0)

Change it to return g<h?1:(g>h?-1:0) and you should be done. 改变它return g<h?1:(g>h?-1:0)你应该完成。

Edit: 编辑:

If you click on the Name cell of the intial column, it also sort in descending order. 如果单击初始列的“ Name单元格,它也会按降序排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM