动态列默认过滤器 TableSorter

Dynamic Columns default filter TableSorter

我目前有一个 table,它有一个动态列,比方说基于下面关于 jsfiddle 的示例,AlphaNumeric 列将仅根据变量值(不包括逻辑)可见。

http://jsfiddle.net/Mottie/856bzzeL/1088/

现在这给 filter_defaultFilter 小部件选项带来了问题,因为它基于列号。如果我有一个隐藏的列 - 默认过滤器将不会应用于指定的列号,因为列索引已更改

filter_defaultFilter: {
    // Ox will always show
    2:{q}|Ox
 }

有没有办法实现默认过滤器背后的逻辑以动态 select 列号?甚至使用列 ID 或 class 来设置默认过滤器?

filter_defaultFilter: {
    // Ox will always show
    if(true) {
        2: '{q}|Ox'
    } else {
        1: '{q}|Ox'
    }
  }

  filter_defaultFilter: {
    // Ox will always show
     [column.id]: '{q}|Ox'
  }

filter_defaultFilter option does allow you to set the value by column class name or ID. In the example, change the column zero-based index 2 to '.animals' (demo):

filter_defaultFilter: {
  // Ox will always show
  '.animals': '{q}|Ox'
}