开发者

tinytable how to sort table in descending order rather then ascending

I'm using开发者_如何转开发 the tinytable table sorting script.

See example at http://sandbox.scriptiny.com/table-sorter/index.html.

It's a very basic script about 2.5kb. To use the script we do sorter.init("table",1); where table is the table id and 1 is the initial column to be sorted. This works great but initial column is sorted in asc order. 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. What do I need to do to make it the initial column sort in desc order?


One line of the script reads return g>h?1:(g<h?-1:0).

Change it to return g<h?1:(g>h?-1:0) and you should be done.

Edit:

If you click on the Name cell of the intial column, it also sort in descending order.


I am working on this and to sort the table in a descending order just change the sort direction to be -1

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜