CSV to html – preserve filter when searching

When you search all rows in the table will be searched even if there are an inital filter as default. It’s possible to keep/preserve the filter you have defined when searching.

Original

SR.NAMEGENDERAGEDATE COUNTRY
1Dett2Female3616/08/2020Great Britain
2Nern Female1915/10/2017France
3KallsieMale2016/08/2016France
4SiuauFemale2121/05/2015Great Britain
5ShenniceMale2221/05/2016France
6ChasseFemale2315/10/2018France
7TommyeMale2416/08/2017United States
8DorcastFemale2521/05/2016United States
9AngeleeMale2621/05/2017Great Britain
10WilloomFemale2615/10/2019France

This example below shows all females that are 19 or older.

Shortcode
[csvtohtml_create source_type="guess" source_files="free_testdata_10rows.csv" filter_col="Gender,Age" filter_data="Female,19" filter_criterias="Gender,Age" filter_operator="equals,mequal"]
SR.NAMEGENDERAGEDATE COUNTRY
1Dett2Female3616/08/2020Great Britain
2Nern Female1915/10/2017France
4SiuauFemale2121/05/2015Great Britain
6ChasseFemale2315/10/2018France
8DorcastFemale2521/05/2016United States
10WilloomFemale2615/10/2019France

If you add search functionality to the table, search for Kallsie and you hit the searchbutton you will see this (because all rows in the table are searched – the filter that you have you have defined before is ignored):

SR.NAMEGENDERAGEDATE COUNTRY
3KallsieMale2016/08/2016France

If you want to preserve filter while searching, you have to add preservefilter_search=”yes” to the shortcode. When you do this only values are searched in columns that are not defined in your filter (In this case search is not done in columns Gender and Age).

Shortcode
[csvtohtml_create source_type="guess" source_files="free_testdata_10rows.csv" preservefilter_search="yes" filter_col="gender,age" filter_data="Female,19" filter_criterias="Gender,Age" filter_operator="equals,mequal"]

If you do the same search again (Kallsie) no rows will display because Kallsie isn’t valid within the range of the filter you have defined (females with age 19 or older). Kallsie is a male.

SR.NAMEGENDERAGEDATE COUNTRY

If you on other hand search for Dorcast you will see this row (because the search are valid within the filter you defined – females that are 19 or older):

SR.NAMEGENDERAGEDATE COUNTRY
8DorcastFemale2521/05/2016United States

Try it yourself with above table and filter

:

Preserve filter off (default):

SR.NAMEGENDERAGEDATE COUNTRY
1Dett2Female3616/08/2020Great Britain
2Nern Female1915/10/2017France
4SiuauFemale2121/05/2015Great Britain
6ChasseFemale2315/10/2018France
8DorcastFemale2521/05/2016United States
10WilloomFemale2615/10/2019France

Preserve filter on:

SR.NAMEGENDERAGEDATE COUNTRY
1Dett2Female3616/08/2020Great Britain
2Nern Female1915/10/2017France
4SiuauFemale2121/05/2015Great Britain
6ChasseFemale2315/10/2018France
8DorcastFemale2521/05/2016United States
10WilloomFemale2615/10/2019France