简体   繁体   English

如何过滤jQuery DataTables中的列?

[英]How to filter columns in jQuery DataTables?

Filter rows in DataTables as follows: 过滤DataTables中的行,如下所示:

$.fn.dataTableExt.afnFiltering.push(
    function( oSettings, aData, iDataIndex ) {
        if ( aData[3] == 'ru' )
        {
            return true;
        }
        return false;
    }
);

And here is how to filter the columns? 这是如何过滤列的? For example I have columns ( http://jsfiddle.net/JLvWu/ ): 例如,我有专栏( http://jsfiddle.net/JLvWu/ ):

Date   |      City1      |      City2      |      City3        |
       | Revenue | Costs | Revenue | Costs | Revenue | Costs   |

How to make so that when you filter by city there was only one city that is selected, and all other columns disappear? 如何使您在按城市进行筛选时仅选择一个城市,而所有其他列都消失了? For example, if the user selected in the cities-filter City1, the table must be changed as follows: 例如,如果用户在“城市”过滤器“城市1”中选择,则必须按如下所示更改表:

Date   |      City1      |
       | Revenue | Costs |

有datatables文档,该文档显示了如何动态隐藏/显示列: http : //www.datatables.net/examples/api/show_hide.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM