riklomas / quicksearch

A jQuery plugin for searching through tables, lists, etc quickly
http://www.lomalogue.com/jquery/quicksearch/
680 stars 261 forks source link

filter all but header rows? #31

Closed Aesculapius closed 13 years ago

Aesculapius commented 13 years ago

Loving your quicksearch... I'm using it to filter all sorts of tables. But often, I create some kind of grouping, by having several rows underneath a header row. As in:

[table] [tr] [th colspan="2"]Section 1[/th] [/tr] [tr] [td]actual row 1[/td][td]actual value 1[/td] [/tr] [tr] [td]actual row 2[/td][td]actual value 2[/td] [/tr] [/table]

Now when I search, I want to search both the td's as the th's. That's working fine since my selector sais: "table#result tbody tr".

But if something is matched in a detailed row, the "header" row isn't matched thus hidden.

I'm looking for a way to always include the header part of a search result, because else it becomes hard to distinguish different results with the same name.

Something like that possible at all? I thought about using the Show option to include a selector for the header part, but then...then Hide option would remove it again?

Edit: by the way: if I use "table#result tbody tr:has(td)" as selector, it works as expected, except that now all headers are shown, instead of only the ones who have search results...

riklomas commented 13 years ago

You could use put classes on the section header rows and then use the jQuery :not selector (http://api.jquery.com/not-selector/) to filter them

Aesculapius commented 13 years ago

But the thing is; I dó want to search within them, they should just always be visible when a match has been found in either the header row or one of the normal rows underneath. Or am I misinterpreting your reply?