DataTables provides two different search plug-in APIs, creating a very powerful and flexible system that will provide logic for almost any search criterion you wish, based on user input.
DataTables supports two different kinds of plug-in search methods:
- Type based search
- Row based search
Server-side processing: If you are using server-side processing (
serverSide), DataTables doesn't do any client-side searching, so these plug-ins will not have any effect. In server-side processing mode, all data manipulation is done by the server - so you would need to implement whatever search logic you require there.
Type based search plug-ins modify the data to be searched upon for each individual cell. A type can be applied to a column using the
columns.type option, and can effect both ordering and searching by changing the data to be used.
As an example, a column with formatted telephone numbers in it might benefit from the table user being able to search the table for the number in its formatted state (
555-1234) or in its unformatted state (
5551234), allowing them more natural search input.
|phoneNumber||Make phone numbers searchable formatted or unformatted|
|diacritics-neutralise||Replace accented characters (diacritics) with latin equivalents|
|accent-neutralise||Replace accented characters with unaccented counterparts|
|html||Strip HTML using DOM methods|
Row based search provides you with complete control over a row - whether it is included in a search result or not based entirely upon your own input and your own search logic. This can be used for complex search operations such as range filters or fuzzy matching.
These filters are global and will be applied whenever DataTables applies its own filtering.
In the following example the range filtering plug-in is saved to a file, and used in the DataTable which is initialised. Note also that an event listener is attached to two
input's, which will cause the table to redraw, and thus filter the new data:
|TableTools.ShowSelectedOnly||Show only selected rows, or all rows, through filtering|
|range_numbers||Filter the data between two numbers (inclusive)|
|range_dates||Filter the table based on two dates in different columns|