Difference between search and filter option.
Difference between search and filter option.
Ramprakash
Posts: 14Questions: 7Answers: 1
Can anyone say exactly what are difference between search and filter options.
In which case we need to prefer filter instead of search?\
I need mulitple filtering in mulitple columns,
Example:
Search a string in 0th column, search another string in 3rd column and search another string in all columns and combine all the result together and draw. What should I need to use??
This question has accepted answers - jump to:
This discussion has been closed.
Answers
A bit unrelated to the q' , but if you will apply my yadcf filter to your table you will be able to use the exFilterColumn function to achieve your goal
In most cases the terms filter and search in DataTables are interchangable. I have make the terminology constant in the 1.10 API and options that to find data in the table is called a search.
The API also has a method called
filter()
. This is not the same assearch()
.fitler()
operates on the data contained in the API result set - not the table.Allan
@daniel_r exFilterColumn has three types, and second is somewhat related but my need is one search criteria is to search in all the columns remaining two each in only one column.
@Ramprakash , there is only one way to call the function, you need to provide two args, first one is the table and the second argument is array of pairs: column number and String/Object with from and to, filter_value (the actual string value that we want to filter by), the "three types" are three examples of calling the function
Wow.. Sounds great.. Its really nice working with datatables.. Thank you allan..
Yes @daniel_r just now i look over the function. I've used solution by Allan and it gave the exact result what I want. Thank you for the reply :-)
@Allan But one problem exists there..
In the search criteria on column 0 I need to search multiple strings, and I need to find exact match..
Ex:
I may have values like Person #1, Person 2,... Person #11,...Person #21...
Based on my code I've given like
$('#example')
I need only rows that have entries either Person #1 or Person #2 not Person #11, Person #21 like that...
It takes last one correctly and filters Person #2 correctly but not for #1.. How can I achieve it??
The regex is incomplete for such a match - just adding parenthesis should do it:
My regex is seriously rusty(!) so you might want to check that (I've just done a cursory check which appears to confirm that).
Allan
@Allan You are really amazing.. Working nice.. Thanks a lot :-)