Filtering data in a row before searching.

Filtering data in a row before searching.

KarinKarin Posts: 5Questions: 0Answers: 0
edited October 2011 in General
For a few months now I am working on a project where we use dataTables, and I'm surprised how powerful it is!!

However I have some issues with the search box where I have not found a proper solution for yet.

I am working with a large datatable (Version 1.7.3) where some columns contain 'hidden' objects next to the 'visible' text. With hidden objects I mean tooltips and other divs which popup when you click on a cell.
When entering a search query in the search box it will also search in those hidden fields. This is confusing for the users since they do not 'see' that data directly; Therefore, I would like to exclude those hidden fields from the search.

To do that I could define a new sType 'html_ext' and add this to the function '_fnDataToSearch' such that it checks if the div is displayable or not before returning the content. However, I still would like to use the default (sType='html') sorting and filtering for those columns without having to add or copy code for them.
(The jquery.dataTables files are used in a few large projects and are therefore defined as 'untouchable'. To avoid introducing problems in other projects it is not allowed to change anything unless it is absolutely necessary.)

In an ideal world, I would like to add a custom function to certain columns (which contain the hidden data) to filter out unwanted data for the search box without having to define new filtering or sorting functions.
I was wondering if it was possible to do something like is done with the 'bSearchable' variable (http://www.datatables.net/usage/columns). With 'bSearchable' it is possible to exclude certain columns from the search. But instead of providing a Boolean (weather to search or not) I'd like to give a filtering function.

On the forums I found one related thread: (http://www.datatables.net/forums/discussion/145/modify-cell-contents-prior-to-filtering/p1), however I cannot modify the default sType 'html' because it is used in other columns (and other projects).

I’m looking for ideas/solutions for solving this issue.
Thanks,
Karin

Replies

This discussion has been closed.