2010-06-14 78 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属性)来解决该问题。