Tablesorter - emptyTo 不工作

Tablesorter - emptyTo not working

我似乎无法让 Mottie 的 Tablesorter "emptyTo" 工作,排序有效,但空单元格排序到顶部,这是我不想要的。我并没有尝试做任何特别的事情,我只是对常规文本进行排序,恰好有空单元格,我更愿意将其排序到底部。

我尝试使用 "emptyTo" tablesorter 属性来自:http://mottie.github.io/tablesorter/docs/example-option-sort-empty.html 但空白区域仍然排序到顶部。

这些是包含的脚本:

我正在使用 coffeescript:

tableOptions =
  emptyTo: 'bottom', //<---- This is the property that should work but isn't :(
  showProcessing: true,
  widthFixed: true,
  widgets: ['zebra', 'stickyHeaders'],
  widgetOptions:
    stickyHeaders: '',
    stickyHeaders_offset: 0,
    stickyHeaders_cloneId: '-sticky',
    stickyHeaders_addResizeEvent: true,
    stickyHeaders_includeCaption: true,
    stickyHeaders_zIndex: 2,
    stickyHeaders_attachTo: null,
    stickyHeaders_filteredToTop: true
    stickyHeaders_attachTo: '.scroll'

然后...

$ ->
  $('.tablesorter').tablesorter(tableOptions)

我的table结构是标准的table排序器结构:

<table class="tablesorter">
  <thead>
    <tr><th></th></tr>
  </thead>
  <tbody>
    <tr><td></td></tr>
  </tbody>
</table>

我也在这个应用程序中使用 bootstrap,所以我不确定这是否会影响它...如果我遗漏了什么,请告诉我。

配置正确,它有一些冗余设置(即无论如何都是默认设置),但安全总比后悔好。第 2 行的注释不是有效的 CoffeeScript 语法,但这是为了在 Stack Overflow 上摆姿势。

既然你提到了 table 是使用 javascript (或 CoffeeScript,它归结为同一件事)生成的,那么生成数据和使用 tablesorter 的顺序重要:

  1. 加载任何库
  2. 加载生成器脚本
  3. 加载table排序器脚本

如果使用工作流工具,例如 grunt、gulp 等,并且脚本被编译成单个脚本,那么遵守此顺序也很重要。列出的两个工具都可以指定包含脚本的顺序。