【问题标题】:tablesorter external input filter applied to two columns and starts with input valuetablesorter 外部输入过滤器应用于两列并以输入值开头
【发布时间】:2015-08-17 14:28:11
【问题描述】:

我正在学习表格排序器并尝试制作过滤器外部输入。它过滤两列(姓名和姓氏)。过滤器必须搜索以输入文本字段内容开头的字符串。他们分开工作。

显然,使用 filter_startsWith : true 无法过滤超过两列。如果我把它们放在一起,它会返回一个空集。

HTML:

<input type="text" id="search" data-column="1,2" type="search"/>

脚本:

var tableSorterOptions = 
        {   
            widgets: ["filter","pager"],
            widgetOptions : 
            {
                filter_columnFilters: false,
                filter_external : '#search',
                filter_startsWith : true                    
            },
            debug: true
        };

        $(document).ready(function() 
        {       
            $('#tabla')         
                .tablesorter(tableSorterOptions);           
        });

我已经尝试删除 filter_startsWith : true with:

        filter_defaultFilter :
        {
            1: '/^{q}/',
            2: '/^{q}/'
        },

在 widgetOptions 中从字符串 (/^{q}/) 的开头搜索名字和姓氏 (1 & 2) 但它不起作用。

你能不能给点小费。

非常感谢

【问题讨论】:

    标签: filter external tablesorter


    【解决方案1】:

    似乎存在导致 javascript 错误的错误。我刚刚修复它并推出了一个新版本(v2.23.0)。 Here is a demo 使用此代码:

    /* Documentation for this tablesorter FORK can be found at
    * http://mottie.github.io/tablesorter/docs/
    */
    $(function () {
        $('table').tablesorter({
            theme: 'blue',
            widgets: ['zebra', 'filter'],
            widgetOptions: {
                filter_columnFilters: false,
                filter_startsWith: true,
                filter_external : '#search',
                filter_defaultFilter: {
                    // 7 = "any" match filter index (total table columns + 1)
                    7 : '{q1} or {q2}'
                }
            }
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-11
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多