Have Datatables come up with an Exclude field yet?
Have Datatables come up with an Exclude field yet?
![spacemancw](https://secure.gravatar.com/avatar/6ea28939738042902adbe59c5b7bc36d/?default=https%3A%2F%2Fvanillicon.com%2F6ea28939738042902adbe59c5b7bc36d_200.png&rating=g&size=120)
Is there and exclude field for DataTables?
Datatables is fantastic for searching tables. But sometime you get more results than you need to it is necessary to exclude some key word or words, so that you can exclude rows. Actually it would be nice to be able to search for multiple words and exclude multiple words.
This question has an accepted answers - jump to answer
Answers
For that level of control over the search, it's worth looking at SearchBuilder. There, you have complete control over searches that can be made, for example with strings you can choose "Does not contain", "Does not start with", etc., and you can create additional search conditions if the provided ones are not comprehensive enough.
Colin
It isn't ready for release yet, but DataTable 2's smart filter has been updated to include a negative match - similar to Google you can add a
!
before a string to make it a negative search.Planning for a beta this month (October).
Allan
Allan thanks for the reply.
Just to complicate matters .... will you have a way to search for multiple items in the search field while also excluding multiple items in the exclude field?
I have both of these functions working with java script, but I could never get them working with DataTables. I can only get them to work with a HTML table without pagination. This is not very pretty with big tables with thousands of rows, but it works.
Here is the code.
and this is what I put in html
The first cell in the row contains the data from all the other rows, but it is hidden and not displayed, and the search/exclude works on that cell.
The first cell looks like this,
I could have data that looks like this:
Type Name Client
Router NY-rtr01 ABC
Router TX-rtr01 XYZ
Router SF-rtr01 DEF
Switch NY-sw01 DEF
Switch SF-sw01 ABC
WifiAP TX-ap01 DEF
WifiAP SF-ap01 XYZ
Search for router and WifiAP
Router NY-rtr01 ABC
Router TX-rtr01 XYZ
Router SF-rtr01 DEF
WifiAP TX-ap01 DEF
WifiAP SF-ap01 XYZ
Search for router and WifiAP, exclude NY, TX
Router SF-rtr01 DEF
WifiAP SF-ap01 XYZ
It doesn't work with Datatables because it only works on the data that is on the page, so if u have 10.000 rows, and only showing 50 at a time with pagination, it only works on those 50.
Sounds like you are using client-side search with server-side pagination.
DataTables when in client-side processing mode will perform search on all rows that you have in the table. If it is in server-side processing mode then all search operations will be done at the server-side. You cannot mix processing modes. There is an overview of them available here.
If you were to use the new DataTables 2 client-side smart filter you could use
WifiAP !NY !TX
for the search. Although it sounds like you want an "OR" expression in there. Without regex that that isn't an option in the smart filter. For more complex searches like that, use SearchBuilder as Colin mentioned above.Allan