Does anyone know how I can make alternating css colors for each row in [size=2]CListView?[/size]
Does anyone know how I can make alternating css colors for each row in [size=2]CListView?[/size]
It seems that there is no such an option.
You should extend CListView and implement. You can take inspiration from the code of CGridView.
CListView calls itemView (http://www.yiiframew…itemView-detail) for rendering…
In that file you can use $index (refers to the zero-based index of the data item currently being rendered) to choose a css class
something like
_view.php
<div class="<?php echo $index%2 ? 'row1' : 'row2' ?>">
...
</div>
your.css
.row1 {color:red;}
.row2 {color:blue;}
So simple… I have always the mania of extending all…
thanks for your help guys. I have a question though, would the variable $index be accessible in the _view.php automatically, or do i need to do something special?
Check the link I posted before…
as it say there $index (and a few other variables) are available in _view.php, you don’t need to do anything for this…
awesome this works great for my list didn’t realise there were other attributes available to tap on