表格选择器从选择下拉菜单和自定义时间过滤器中选择多个选项? [英] tablesorter select multiple options from select dropdown menu and custom time filter?

查看:275
本文介绍了表格选择器从选择下拉菜单和自定义时间过滤器中选择多个选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从选择下拉菜单中选择多个选项并显示结果。像我的小提琴,我有名字作为第一列,想要选择和显示亚伦和克拉克的时间。单独的可能。但是如果需要选择两个选项呢?如何实现?



而且,如何应用自定义时间过滤器,如


上午(6至12日)



下午(12至18日)



18到21)


这是我试过的,但它不起作用。实际上,这些选项甚至不会显示在选择框中。



http://jsfiddle.net/QJnEa/

  filter_functions:{

1 :{
Morning:function(e,n,f,i){return n < 12; },
Afternoon:function(e,n,f,i){return n> = 12&& n≤18; },
晚上:function(e,n,f,i){return n> 18; }
}

只显示时间。



提前感谢

解决方案

在该演示中,在时间列中有一个类名filter-select,它覆盖 filter_functions 。所有您需要做的是删除该类

 < th data-placeholder =选择时间块>时间& / th 

然后更新filter_function来使用确切的( e )值,而不是标准化值( n ),其实际上是一个非常大的数字(从1/1/2000开始的时间(以秒为单位),由时间解析器)。

  filter_functions:{

1:{
早晨:function(e,n,f,i){
return parseInt(e,10)< 12;
},
Afternoon:function(e,n,f,i){
var num = parseInt(e,10);
return num> = 12&& num = 18;
},
晚上:function(e,n,f,i){
return parseInt(e,10)> 18;
}
}
}

至于第二部分您的问题,过滤器小部件当前不支持多选元素。这可能在将来;但同时,您可能需要查看此演示(仍然在测试版中),它使用表格外部的 select2插件


Is there any way to select multiple options from the select dropdown menu and display the result. Like in my fiddle i have first name as the first column and want to select and display Aaron and Clark's time. Individually its possible. But what about if two options need to be selected. How's that got to be achieved.

And, how do apply custom time filters like

Morning (between 6 to 12)

Afternoon (between 12 to 18)

Evening (between 18 to 21)

Here is what i tried, but it does not work. infact, those options are not even shown in the select box.

http://jsfiddle.net/QJnEa/

   filter_functions : {

    1 : {
      "Morning"      : function(e, n, f, i) { return n < 12; },
      "Afternoon" : function(e, n, f, i) { return n >= 12 && n <=18; },
      "Evening"     : function(e, n, f, i) { return n > 18; }
    }

Showing only for time. Dont know how to code for multiple select.

Thanks in advance.

解决方案

In that demo, there is a class name "filter-select" in the time column which is overriding the filter_functions. All you need to do is remove that class

<th data-placeholder="Select a time block">Time</th>

then update the filter_functions to use the exact (e) value instead of the normalized value (n) which is actually a very large number (time in seconds since 1/1/2000; as defined by the time parser).

filter_functions: {

    1: {
        "Morning": function (e, n, f, i) {
            return parseInt(e, 10) < 12;
        },
        "Afternoon": function (e, n, f, i) {
            var num = parseInt(e, 10);
            return num >= 12 && num <= 18;
        },
        "Evening": function (e, n, f, i) {
            return parseInt(e, 10) > 18;
        }
    }
}

As for the second part of your question, the filter widget doesn't currently support a multiple-select element. It may in the future; but in the mean time, you might want to check out this demo (still in beta) that uses the select2 plugin external to the table.

这篇关于表格选择器从选择下拉菜单和自定义时间过滤器中选择多个选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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