2010-06-14 60 views
1

我不確定這裏出了什麼問題。這是頁面:http://www.utexas.edu/ssw/cswr/projects/project-list/jQuery Tablesorter - 列不按字母順序排序

第一列排序,但它沒有以正確的順序(按字母順序)返回數據。

該表本身是由自定義PHP函數生成的,該函數從WordPress數據庫中提取信息。我認爲這可能是問題,但正如你可以看到第四列(結束日期)正確排序。我還認爲這可能是第一列中的鏈接搞砸了,但添加this page的文本提取代碼完全打亂了排序。

這是jQuery代碼我當前使用調用的tablesorter:

<script type="text/javascript" id="js"> 

    jQuery(document).ready(function($) { 
     $(document).ready(function() { 
      // call the tablesorter plugin, the magic happens in the markup 
      $("#projectTable").tablesorter({ 
       // pass the headers argument and assing a object 
       //debug: true, 
       //sortList: [[0,0]], 
       headers: { 
        0: { 
        // set the column to sort as text 
         sorter: 'text', 
        }, 
        // 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 
        }, 
        3: { 
         sorter:'digit' 
        } 
       } 


      }); 

       // Works only with plugin modification 
       $("#projectTable").bind("sortStart",function(e) { 
        if($(e.target).hasClass('header')) { 
         $("#overlay").show(); 
        } 
       }).bind("sortEnd",function(e) { 
        if($(e.target).hasClass('header')) { 
         $("#overlay").hide(); 
        } 
       }); 

     }); 
    }); 
</script> 

感謝您的幫助!

回答

2

由於鏈接了元素,因此您需要將textExtraction定義爲complex

參見:http://tablesorter.com/docs/#options

+0

我嘗試添加 textExtraction:複雜, 只是在上面的代碼中的「頭」行之前,但它打破完全排序。我也嘗試了文檔中列出的關於textExtraction的所有示例,但它們也不起作用 - 我可能沒有將它們放在正確的位置?謝謝你的幫助! – Michelle 2010-06-14 20:44:08

+0

沒關係! :)我在單詞'complex'周圍添加了單引號,它工作。謝謝! – Michelle 2010-06-14 20:44:56

+0

不客氣。 – 2010-06-14 20:52:08

1

問題是,它是由鏈接中的URL排序而不是文本。

您可能需要創建自定義排序條件(textExtraction屬性)來解決該問題。