代码之家  ›  专栏  ›  技术社区  ›  Michelle

jquery tablesorter-列没有按字母顺序排序

  •  2
  • Michelle  · 技术社区  · 16 年前

    我不知道这里出了什么问题。这是页面: http://www.utexas.edu/ssw/cswr/projects/project-list/

    第一列排序,但没有按正确的顺序(按字母顺序)返回数据。

    表本身是由一个从WordPress数据库中提取信息的自定义PHP函数生成的。我认为这可能是问题所在,但正如您所看到的,第四列(结束日期)的排序是正确的。我还认为可能是第一列中的链接把事情搞砸了,但是添加了文本提取代码 this page 完全破坏了排序。

    这是我当前用来调用TableSorter的jQuery代码:

    <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 回复  |  直到 16 年前
        1
  •  2
  •   Aaron Butacov    16 年前

    你需要定义 textExtraction 作为 complex 因为元素中有链接。

    见: http://tablesorter.com/docs/#options

        2
  •  1
  •   Powerlord    16 年前

    问题是,它是根据链接中的URL而不是文本进行排序的。

    您可能需要创建自定义排序条件 textExtraction 属性)修复。

    推荐文章