茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1669412 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00355.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2012/10/23 1:15:30
tablesorterSet 官方範例:

1.預設排序欄位(Set a initial sorting order using options):
$(document).ready(function() {
  // call the tablesorter plugin
  $("table").tablesorter({
    // sort on the first column and third column, order asc
    sortList: [[0,0],[2,0]]
  });
});

說明:
利用 sortList 給定預設一起動要排序的欄位
參數是二維陣列
第一碼決定排序欄(直欄,從 0 開始)第二碼決定 asc 或 desc(0 表 asc 1 表 desc) ex : [0,0]
如果要多欄位一起排序的話,再繼續往上加,如範例中的第一欄與第三欄升冪排序 ex : [[0,0],[2,0]]

2.取消某些欄位排序功能(Disable header using options):
$(document).ready(function() {
  $("table").tablesorter({
    // pass the headers argument and assing a object
    headers: {
      // assign the secound column (we start counting zero)
      1: {
        // disable it by setting the property sorter to false
        sorter: false
      },
        // assign the third column (we start counting zero)
      2: {
        // disable it by setting the property sorter to false
        sorter: false
      }
    }
  });
});

說明:
利用 headers 給定不提供排序功能的欄位
參數是告訴他哪個欄位 sorter: false
先決定哪個欄位不能排序,把他的 index 寫上 ex : 1:
然後告訴 tablesorter 不給排序 ex : { sorter: false }

3.不使用 header 來排序(Sort table using a link outside the table):
$(document).ready(function() {
  $("table").tablesorter();
  $("#trigger-link").click(function() {
    // set sorting column and direction, this will sort on the first and third column the column index starts at zero
    var sorting = [[0,0],[2,0]];
    // sort on the first column
    $("table").trigger("sorton",[sorting]);
    // return false to stop default link action
    return false;
  });
});

說明:
建立一個 link 來提供排序功能
所以要先建立一個 link 並把他的 id 設成 trigger-link ex : sort first and third columns
然後再 Jquery 的 JavaScript 中把他設定好 ex : $("#trigger-link").click(function()
先決定哪些欄位是點擊本 link 時會排序的欄位 ex : var sorting = [[0,0],[2,0]];
再告訴 Jquery link 被 trigger 時要做啥(當然就是排序啦) ex : $("table").trigger("sorton",[sorting]);
最後傳回一個 false 來結束本 action ex : return false;

4.強制排序某欄位(Force a default sorting order):
$(document).ready(function() {
  // call the tablesorter plugin
  $("table").tablesorter({
    // set forced sort on the fourth column and i decending order.
    sortForce: [[0,0]]
  });
});


5.改變多欄位排序時的選定鈕(Change multi-column sorting key)
$(document).ready(function() {
  // call the tablesorter plugin
  $("table").tablesorter({
    // change the multi sort key from the default shift to alt button
    sortMultiSortKey: 'altKey'
  });
});


6.Dealing with digits
$(document).ready(function() {
  // call the tablesorter plugin
  $("table").tablesorter();
});


註:沒寫說明的幾個 example 是冷日覺得沒用到,也看不太懂的 example,先擺著吧,未來有空再來找機會更新!


原文出處:http://tablesorter.com/docs/index.html#Examples
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|