I found some approaches to alternete colors using Javascript, but I can hide some elements in my table/datagrid but with this CSS the bg color doesn't alternate correctly:
CSS
.grid tr:not(.display-none):nth-child(2n+1) > td {
background: red;
}
.display-none * {
display: none;
}
HTML
<table class="grid">
<tr><td>nono1</td></tr>
<tr><td>nono2</td></tr>
<tr><td>nono3</td></tr>
<tr><td>nono4</td></tr>
<tr class="display-none"><td>nono5</td></tr>
<tr><td>nono6</td></tr>
<tr><td>nono7</td></tr>
<tr><td>nono8</td></tr>
</table>
See the live sample