【问题标题】:Tablesorter set filter setup to multiple columnsTablesorter 将过滤器设置设置为多列
【发布时间】:2016-09-28 13:33:01
【问题描述】:

我找到了一个过滤器配置来过滤空列。 问题是我只知道如何将其应用于一列(在示例列号 8 中)。我想同时将其应用于其他列(例如第 8、12 和 17 列)。 谢谢!

filter_functions: {
            8: {
                '{empty}' : function (e, n, f, i, $r, c) {
                    return $.trim(e) === '';
                }
            }
        },
        filter_selectSource: {
            8: function (table, column, onlyAvail) {
                // get an array of all table cell contents for a table column
                var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
                // manipulate the array as desired, then return it
                array.push('{empty}');
                return array;
            }
        }, 

【问题讨论】:

    标签: filter multiple-columns tablesorter


    【解决方案1】:

    filter_functionsfilter_selectSource 选项都将接受包含 jQuery 选择器的对象键以及从零开始的列索引。例如,如果列标题 8、12 和 17 的类名都是“add-empty”,则设置选项如下:

    filter_functions: {
      '.add-empty' : {
        '{empty}' : function (e, n, f, i, $r, c) {
          return $.trim(e) === '';
        }
      }
    },
    filter_selectSource: {
      '.add-empty' : function (table, column, onlyAvail) {
        // get an array of all table cell contents for a table column
        var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
        // manipulate the array as desired, then return it
        array.push('{empty}');
        return array;
      }
    }
    

    【讨论】:

    • 谢谢莫蒂先生!!我还发现,如果在常规过滤器中点击:“”,您也只会过滤空单元格。
    • 像这样打开和关闭双引号 -> ""
    猜你喜欢
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    相关资源
    最近更新 更多