koalyptus / TableFilter

A Javascript library making HTML tables filterable and a bit more :)
https://www.tablefilter.com
MIT License
323 stars 95 forks source link

CSS striped rows #755

Closed Qlii256 closed 4 years ago

Qlii256 commented 4 years ago

When using CSS3 selector nth-child to style even and odd rows with a different background, this is not "updated" when doing a filter (search). The data (rows) keep their previous background style and you end up with multiple of the same colour next to each other.

This is caused by CSS behaviour, as display: none does not remove the row, but just "hide" it. CSS does not care and keeps them as normal rows when "calculating" odd and even rows. I was wondering if there's anything that could be done about this issue. Perhaps store all data in an array, and remove the data that's filtered out so the table only holds the actual visible data.

Steps to reproduce the behavior:

  1. [Enter text into a filter input, that at least gives you two rows of the same odd/even rows]
  2. [Notice, that some rows below each other will have the same odd/even styling]

Expected behavior Tables should keep actual visible data only, and store filtered data in an array.

Screenshots

Notice the same darker grey background on the last 3 values. These are all odd rows, while the 1st one is an even row.

TableFilter version: [0.6.104] Browser and version: [Chrome, latest stable] OS and version: [MacOS 10.15.1] Device: [Macbook Pro Retina Early 2013]

Additional information/context: Add any other context about the problem here.

Qlii256 commented 4 years ago

I'm dumb, only just noticed there's an option to have odd and even classes added automatically by setting alternate_rows: true.