简体   繁体   中英

How to filter columns in jQuery DataTables?

Filter rows in DataTables as follows:

$.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/ ):

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:

Date   |      City1      |
       | Revenue | Costs |

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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