2012-02-13 88 views
-2

我想排序我的网格中的数字列以降序在第一次点击。谁能帮我这个?设置数字列tablesorter的初始排序顺序jquery

+0

[你尝试过什么?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – 2012-02-13 15:42:41

+0

布莱恩嗨,我使用TableSorter插件的jQuery。我在其中设置了默认设置。但我无法分别为每列指定初始排序顺序。你能帮忙吗? – Ven 2012-02-13 16:04:41

回答

0

法师,

使用 “sortlist中” 选项表示要在降序排序(1),而不是升序(0)。

文档说:

“sortlist中” - 在每格式列排序和方向的指令的数组:[[columnIndex,sortDirection],...],其中columnIndex是基于零的索引对于您的列从左到右,sortDirection对于升序是0,对于降序是1。首先按列1然后按列2排序的有效参数看起来像:[[0,0],[1,0]]。

例如

$(document).ready(function() { 
// call the tablesorter plugin 
    $("table").tablesorter({ 
     // sort on the first column and third column, order descending (1) 
     sortList: [[0,1],[2,1]] 
    }); 
}); 

问候尼尔

+0

嗨尼尔,非常感谢您的快速回复。我知道这一点。但是这会在加载期间按降序对数字列进行排序。我不需要这个。我需要的是,在第一次单击标题时,只有网格中的数字列应按降序排序,而其他列应在第一次单击标题时按降序排列。 – Ven 2012-02-13 16:20:05

+0

要更改初始排序顺序,请将'sortInitialOrder'选项设置为''asc“'或'”desc“' - 获取更多详细信息[here](http://wowmotty.blogspot.com/2011/06/jquery -tablesorter缺失,docs.html) – Mottie 2012-02-20 03:30:04