Automatic Filter

Pre-filter a table when it is shown.

Sometimes it can be useful to initialize the “Search:” field above a table with a filter word. The advantage of this method over the Row Filtering module is, that the site visitor can change the filter word, to e.g. show all entries in the table.

Feature description

Here is an example with a pre-filled Search field:

Last NameFirst NameBirthdayCompanyPhone (Ext.)ZIP codeCountryBalancePointsRating
BanksTravis05/04/1969Apple200-432464655Italy$61.1786.6
CainLawrence05/16/1994IBM701-310898004United States$54.8152.5
MiddletonDennis01/10/1992Google580-950180913Spain$24.8345.2
ValenzuelaLunea01/09/1966Cisco970-865551606Germany$74.0773.7
BurgessQuynn09/24/1988Mozilla430-894378965France$16.1382.9
LottLillith12/10/1978Dell587-228988178Australia$30.1217.9
FreemanCheyenne01/28/1981LG396-547314711Germany$49.8216.0
HoustonJorden05/03/1978Adobe970-118296036Canada$47.3121.5
HarrisMerritt12/29/1989Apple160-597725178United States$77.3360.1
GregoryBrynn01/13/1994Adobe663-603991558Spain$90.2498.2
CurryMason03/15/1969Sony115-477887513Australia$21.6856.6
HollandAlyssa06/25/1976Xerox704-497797921Canada$50.3179.5
LoganShay09/13/1968IBM687-648203023United States$46.3987.6
MoranAugust07/04/1986Cisco651-121460737India$22.6417.5
VasquezKelsey03/31/1968Samsung470-735879655Germany$84.0534.5
SteinLawrence10/15/1960Toshiba929-540736044Italy$77.1128.6
BattleWylie01/03/1988Facebook368-227637585Australia$46.37102.8
BookerLogan12/16/1975Apple830-570122074United States$40.7119.0
GilbertChaney06/06/1970Sony132-556089630Canada$78.4591.2
BuckleyStone09/11/1980Cisco422-799874057United States$30.0127.9

Usage instructions

To use this feature with your tables, enable the “Automatic Filter” module on the TablePress “Modules” screen.

Then, activate and configure the feature for the desired tables in the “TablePress table” block or use the Shortcode

[table id=123 datatables_auto_filter=test /]Code language: JSON / JSON with Comments (json)

to have the table filtered for test when the page is loaded. Change the 123 to your table’s ID.

Or, you could use

[table id=123 datatables_auto_filter_url_parameter=table_filter /]Code language: JSON / JSON with Comments (json)

to enable URLs like

https://example.com/page-with-table/?table_filter=wordCode language: HTML, XML (xml)

so that the filter term will be extracted from the URL parameter table_filter.