使用Jquery Tablesorter,如何使其中一列成为页面加载时进行排序的默认列? [英] Using Jquery Tablesorter, how to make one of the columns the default one that sorts when the page loads?
问题描述
我有一个3列的表格(名称,作者和日期).页面加载时,默认情况下它将对第一列(名称)进行排序.页面加载时,默认情况下如何使它对第三列(日期)排序?它与sortList有关吗?感谢您的帮助.
I have a 3 column table (name, author, and date). When the page loads, it sorts the first column (name) by default. How can I make it sort the 3rd column (date) by default when the page loads? Is it something to do with sortList? Thanks for any help.
$(document).ready(function()
{
$("#SomeList").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
$("#SomeList").tablesorter({
widgets: ['zebra'],
dateFormat: "uk",
sortList: [[0, 0]],
headers: { 2: { sorter: false}}
});
推荐答案
使用sortList参数初始化表时,还可以传入配置选项:
You can also pass in configuration options when you initialize the table using the sortList argument:
用于按列排序和定向的指令数组 格式:[[columnIndex,sortDirection],...]其中columnIndex是一个 列从左到右的从零开始的索引,sortDirection为0 代表升序,代表1代表降序.排序有效的参数 首先从第1列升至第2列,如下所示: [[0,0],[1,0]]
An array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]
这是在第三列上进行排序的方法
Here's how to sort on the 3rd column
$(document).ready(function() {
// call the tablesorter plugin
$("table").tablesorter({
// sort on the third column, order asc
sortList: [[2,0]]
}); });
参考:
这篇关于使用Jquery Tablesorter,如何使其中一列成为页面加载时进行排序的默认列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!