Re-apply 'zebra' striping after hiding rows
Re-apply 'zebra' striping after hiding rows
I have a server-side data table that's pulls anywhere between 10 - 150 rows from a database. The user is then able to pseudo-filter the results by hiding certain rows.
This is done by applying a certain attribute the each row (based on the value of one of the fields) and then toggling the visibility using a series of checkboxes.
It's all working, apart from the odd/even striping, which obviously doesn't take account of the hidden rows.
Is there a workaround for this issue? I can't think of a way do do it using server-side filtering because the filters all need to be applied to the same field and it's a case of hiding one or more matches rather than showing them.
It may be possible using MySQL's REGEX filters (which I've adapted the server-side code to allow), but I can't get my head around it.
Any ideas are much appreciated.
This is done by applying a certain attribute the each row (based on the value of one of the fields) and then toggling the visibility using a series of checkboxes.
It's all working, apart from the odd/even striping, which obviously doesn't take account of the hidden rows.
Is there a workaround for this issue? I can't think of a way do do it using server-side filtering because the filters all need to be applied to the same field and it's a case of hiding one or more matches rather than showing them.
It may be possible using MySQL's REGEX filters (which I've adapted the server-side code to allow), but I can't get my head around it.
Any ideas are much appreciated.
This discussion has been closed.
Replies
$("#yourtable tbody tr:odd").css({'background-color':'#ccc'});
$("#yourtable tbody tr:even").css({'background-color':'#000'});
[code]tr:ever td { background: #ccc }
tr:odd td { background: #fff }[/code]
To the original issue - it sounds like rows are being hidden by CSS, not by DataTables. If you need rows to be removed, they should be filtered out from the result set using the DataTables API.
Allan