【问题标题】:How to create a tooltip for the filter widget of the JQuery tablesorter plugin?如何为 JQuery tablesorter 插件的过滤器小部件创建工具提示?
【发布时间】:2014-03-07 22:57:49
【问题描述】:

可能相关的问题:jquery tablesorter add title/tooltip to show ascending/descending

以下是我尝试过的 HTML:

<table class="tablesorter" id="table1">
     <thead>
         <tr>
             <th title="this is title for the header" data-title="I want this to be title for the filter">Column1</th>
             <th title="this is title for the header" data-title="I want this to be title for the filter">Column2</th>
         </tr>
     </thead>
     <tbody>
         <tr><td>1</td><td>2</td></tr>
         <tr><td>3</td><td>4</td></tr>
     </tbody>
 </table>

还有 JS:

$('#table1').tablesorter({
    theme : 'ice',
    cssInfoBlock : 'tablesorter-no-sort',
    widgets: ['zebra', 'stickyHeaders', 'filter']
});

标题部分有效。我不知道的是过滤器文本框上的鼠标悬停文本。我不想手动拦截这些事件。

【问题讨论】:

    标签: jquery filter tablesorter


    【解决方案1】:

    最好使用表头上的data-placeholder 属性向过滤器添加占位符 (demo)

    <th data-placeholder="Search Alphanumeric">AlphaNumeric</th>
    

    但如果您真的希望出现工具提示,请尝试以下代码 (demo):

    HTML

    <th data-filter-title="Search Alphanumeric">AlphaNumeric</th>
    

    脚本

    $('table')
        .on('filterInit', function() {
            var c = this.config;
            c.$headers.each(function(i){
                c.$filters.eq(i).attr( 'title', $(this).attr('data-filter-title') );
            });
        })
        .tablesorter({
            theme: 'blue',
            widgets: ['zebra', 'filter']
        });
    

    【讨论】:

    • 好的,我知道这个选项并且正在试验它。顺便说一句,你的图书馆很棒!我提出这个问题的原因是:我正在向非技术人员展示一张数据表。他们想要过滤器小部件提供的类似 Excel 的过滤功能,但要付出很小的代价 - 学习用于过滤的迷你语言。例如,有人向我报告了一个错误,即输入 80 匹配 80 和 580,而他们应该使用 =80。我建议我们链接到您的文档,但这被认为太重了。
    • 解释所有选项的弹出对话框也因为太重而被拒绝。我们正在尝试结合使用占位符和工具提示,您提供了一个工作示例 - 谢谢!我只是想向您指出,新手用户不会立即知道所有选项是什么 - 让他们发现它的最佳方式应该是什么?有些列确实有相同类型的数据,所以理想情况下我会限制用户可以用它做的事情。所有的选择仍然很大。 Excel 发现数据类型并提供一堆菜单。还有其他建议吗?
    • 对于非技术用户来说,拥有slider for numeric columns 和选择文本列会更好吗?我不知道您的表中包含哪些类型的数据,但过滤器功能允许为每列自定义选择。
    • 我看过滑块示例。这是一个好的开始,但 UI 仍然不完美 IMO。使用两侧滑块执行 =80 的等效操作需要精确移动两者。在浮点数而不是整数的情况下,这变得非常痛苦。需要一些思考才能弄清楚“过滤器之间”默认为不过滤,因为最小值为最小值,最大值为最大值。因此,人们可以只使用
    猜你喜欢
    • 1970-01-01
    • 2014-08-11
    • 2012-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多