Standard Filter and Multi Filter for Colums
Standard Filter and Multi Filter for Colums
overhead
Posts: 20Questions: 0Answers: 0
Hello,
I would like to create a table where I have filters in the header and that over each column. There is a standard.
How can I do that for the other columns a text filter is there and there is only one text filter for the columns 3-11?
This discussion has been closed.
Replies
This thread is asking the same question. See if it helps.
Kevin
no is not the same.
i want in colum 0 till 1 only search in the same Colum and the Input Field in Colum 2 search in Colum 2,3,4,5,6,7,8,9,10 and Colum 11 have a own Search field.
In order to target specific columns to search from an input field you can use
columns().search()
. You would specify the columns you would like to search in thecolumns()
function (e.g. to have an input that searches columns 2-10 you would use.columns([2,3,4,5,6,7,8,9,10]).search("search value")
).so my example.
http://live.datatables.net/tagutiwo/1/edit?html,js,output
You see [2,3,4,...] dont work.
Where is the Mistake?
Thanks for the test case. The problem with using
columns().search()
is the search is an AND based search. You can see this here with a modified version of your test case.http://live.datatables.net/piwugixa/1/edit
Search for
mac
and you will see the one row withmac
in all the columns ([2,3,4,5]). I would recommend using a search plugin. Here is an example:http://live.datatables.net/mucevape/1/edit
The example is different than what you want but hopefully it will give you an idea of what to do.
Kevin
Unfortunately, your example involves individual columns and a select menu.
There are supposed to be all lines where Mac is in it.
The large search function searches for everything and does not just an AND Search. Can not you modify them?
Yep, but Kevin's example is sound - you need to have a single
input
element that then uses the search plugin to do the OR search.As I mentioned my example is not exactly what you want but should show you how to do an OR search. I created that example for something else.
I updated you example with a search plugin:
http://live.datatables.net/tagutiwo/2/edit
Note that I changed the event handler from
keyup click
tochange
. The plugin loops through each desired column and if it finds a match it returnstrue
which displays the row. If it doesn't find a match it returnsfalse
which filters the row.If you want to search on each keystroke then you will need to change the search plugin to compare differently, maybe using regex.
Kevin