jQuery Tablesorter - 列不按字母顺序排序

标签 jquery tablesorter

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

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

该表本身是由自定义 PHP 函数生成的,该函数从 WordPress 数据库中提取信息。我认为这可能是问题所在,但正如您所看到的,第四列(结束日期)排序正确。我还认为可能是第一列中的链接把事情弄乱了,但是添加了来自 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>

感谢您的帮助!

最佳答案

您需要将 textExtraction 定义为 complex,因为元素中有链接。

参见:https://mottie.github.io/tablesorter/docs/#textextraction

关于jQuery Tablesorter - 列不按字母顺序排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3040644/

相关文章:

javascript - 基本 jQuery .data() 调用返回未定义

jquery - 给导航链接数据文本属性,其中包含链接文本

javascript - 显示字段,允许按钮编辑和保存 html

jquery - 在 jQuery 中,完全完成调整大小后如何销毁 resizing() 功能?

javascript - 为什么在上游有事件时有一个 'event'变量可用但没有定义?

javascript - 删除以前在 jQuery 中添加的元素

jquery - 动态数据表分页和排序与变化/动态内容

java - 显示 jTable 中两个给定日期之间的元素

tablesorter - 在 jquery tablesorter 中添加过滤器数据占位符

jquery - 对表格进行排序时禁用 <a> 单击