tablesort多选下拉列表

tablesort multiselect dropdown

本文关键字:下拉列表 tablesort      更新时间:2023-09-28

我使用的是tablesorter下拉列表,可以从中选择一个元素。我希望能够选择多个元素。有没有办法使用桌上分拣机?

我试着在这里查找,但我不确定它是否说明了任何直接的方法。这个问题似乎也表明没有直接的方法?

编辑:

代码

        filter_functions : {
            0 : {
                "a" : function(e, n, f, i, $r) { return e===f; },
                "b" : function(e, n, f, i, $r) { return e===f; },
                "c" : function(e, n, f, i, $r) { return e===f; },
                "d" : function(e, n, f, i, $r) { return e===f; }
            }

您可以使用filter_formatter选项和额外的过滤器格式化程序select2代码来使用select2插件。这是一个演示。

filter_formatter : {
  // default settings on first column
  0 : function($cell, indx){
    return $.tablesorter.filterFormatter.select2( $cell, indx, {
      // *** select2 filter formatter options ***
      cellText : '',    // Text (wrapped in a label element)
      match    : true,  // adds "filter-match" to header & modifies search
      value    : [],    // initial select2 values
      // *** ANY select2 options can be included below ***
      // (showing default settings for this formatter code)
      multiple : true,  // allow multiple selections
      width    : '100%' // reduce this width if you add cellText
    });
  }
}

注意:请注意,$.tablesorter.filterFormatter.select2功能还不能与select2 v4.0.0测试版一起使用。使用存储库附带的select2 v3.4.6。