Hide all rows by default, show rows on search

Hide all rows by default, show rows on search

nwnw Posts: 1Questions: 1Answers: 0

Hi All,

I'm looking to reverse the functionality of the search. I want all rows hidden by default, and then when a search term is entered, matching rows become visible.

Is this possible or will I have to write some jQuery to complete this?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    DataTables' "search" is technically a filter rather than a search, since it removes items from a lost based on the input.

    Two options spring to mind though:

    1. Hide the table is there is no search term applied, or
    2. Apply a search term that results in no matching data, and it would be replaced when the end user starts typing.

    Allan

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Here's an example of Allan's first suggestion - it hides the rows when there's on search,

    Colin

Sign In or Register to comment.