Standard Filter and Multi Filter for Colums

Standard Filter and Multi Filter for Colums

overheadoverhead 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?

Replies

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    This thread is asking the same question. See if it helps.

    Kevin

  • overheadoverhead Posts: 20Questions: 0Answers: 0

    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.

  • awelchawelch Posts: 38Questions: 1Answers: 3

    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 the columns() 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")).

  • overheadoverhead Posts: 20Questions: 0Answers: 0
    edited June 2019

    so my example.
    http://live.datatables.net/tagutiwo/1/edit?html,js,output

    You see [2,3,4,...] dont work.
    Where is the Mistake?

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    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 with mac 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

  • overheadoverhead Posts: 20Questions: 0Answers: 0

    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?

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    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.

  • kthorngrenkthorngren Posts: 20,300Questions: 26Answers: 4,769

    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 to change. The plugin loops through each desired column and if it finds a match it returns true which displays the row. If it doesn't find a match it returns false 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

This discussion has been closed.