Tablesorter:在加载时设置初始过滤器选择值 [英] Tablesorter: Set initial filter-select value on load

查看:138
本文介绍了Tablesorter:在加载时设置初始过滤器选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个tablesorter表,其中一列使用过滤器 - 选择过滤器唯一类。
我想要做的是在下拉列表中的某个值上预先过滤该列。



我已经尝试将其设置为数据占位符属性,但是这并不能解决问题。



我也尝试了以下方法:



$ p $ $(document).ready(function(){
$ .tablesorter.setFilters($(#table ),['','','','','','','','T'],true);
});

正确设置选择菜单中的过滤器,但不会真正运行过滤器。 >

有什么想法?

解决方案

要初始设置过滤器,一个头data-value属性(由




$ p $ p> < table id =table>
< thead>
< tr>
< th> ...< / th>
...
< th data-value =T> ...< / th>
< / thead>
< tbody>
...
< / tbody>
< / table>

您可以在Age列中看到一个例子,其中< 30 最初被设置。 / p>

I have a tablesorter table where a column uses the filter-select and filter-onlyAvail classes. What I'm trying to do is pre-filter that column on one of the values in the drop-down select.

I have tried setting it in the data-placeholder attribute but that doesn't do the trick.

I've also tried the following:

$(document).ready(function(){
    $.tablesorter.setFilters($("#table"),['','','','','','','','T'],true);
});

It correctly sets the filter in the select menu but doesn't actually RUN the filter.

Any ideas?

解决方案

To initially set the filters, add the filter to a header "data-value" attribute (set by the filter_defaultAttrib widget option):

<table id="table">
  <thead>
    <tr>
      <th>...</th>
      ...
      <th data-value="T">...</th>
  </thead>
  <tbody>
  ...
  </tbody>
</table>

You can see an example here in the Age column where <30 is initially set.

这篇关于Tablesorter:在加载时设置初始过滤器选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆