FuzzySearch on selected columns
FuzzySearch on selected columns

I want to use FuzzySearch but only on selected columns
- I have a table with FuzzySearch.
- I need to exclude some of the columns as they are producing unwanted results.
- I need these columns to remain searchable so I can continue using them to produce filter buttons.
Search input function
$("#search_keywords").keyup(function (e) {
if(e.which == 13) {
showTable();
}
// Search and draw (below)
});
Search and draw - Option 1 and 2 work
1. DataTables search on columns 13 and 2:
table.column([13,2]).search($(this).val()).draw();
2. FuzzySearch search on whole table:
table.search.fuzzy($(this).val()).draw();
3. I want this option to work but it doesnt:
table.column([13,2]).search.fuzzy($(this).val()).draw();
Error code when using option 3
DataTable_JS.js:181 Uncaught TypeError: table.column(...).search.fuzzy is not a function
at HTMLInputElement.<anonymous> (DataTable_JS.js:181:33)
at HTMLInputElement.dispatch (student-vendor.min.js:1:44187)
at v.handle (student-vendor.min.js:1:40920)
Thank you in advance.
Replies
I added a
fuzzySearch.columns
option to the Fuzzy Search plugin, for example:I made two changes to the code in the
fuzzySearch()
function. First is to get the defined columns:Second is to compare only the cells in the defined columns:
The modified plugin code is in the Javascript tab. My basic testing seems to work.
https://live.datatables.net/paraqipi/1/edit
Note: the columns option supports providing only an array of column indexes to fuzzy search.
Kevin
Amazing work! Thank you for adding that in.
All testing well from this end.