Why not use pure css for zebra striping? adding classes for odd/even
is rather oldschool...

tbody tr:nth-child(odd) { background-color: #ccc; }

Martijn

On Sun, Feb 15, 2015 at 3:56 PM, Thorsten Schöning
<tschoen...@am-soft.de> wrote:
> Hi all,
>
> I'm using DataView to publish some search results in a HTML table and
> what the results to format zebra style. I've found OddEvenItem for
> that purpose but ran into what I find is a problem: The first item is
> always rendered with CSS class "even", because the index used is 0
> based. That may be correct from a technical point of view, but is not
> what I want to present my users.
>
> So I changed my creation of OddEvenItem to simply not provide index 0,
> but found that my provided index is always ignored. Even if I change
> my index to a constant like 1 it is ignored.
>
> I found the problem in RefreshingView.addItems, where a loop is used
> to iterate over items and an index is always set:
>
>> protected void addItems(Iterator<Item<T>> items)
>> {
>>       int index = 0;
>>       while (items.hasNext())
>>       {
>>               Item<T> item = items.next();
>>               item.setIndex(index);
>>               add(item);
>>               ++index;
>>       }
>> }
>
> This doesn't make sense to me, because the OddEvenItem ctor is
> designed to take an index, which is afterwards ignored.
>
> Two questions here:
>
> 1. Is the call to setIndex by design and one should override setIndex in
> custom created items to just ignore that call? In that case the
> documentation for Item should make that more clear, unless I have
> missed that.
>
> 2. How should I get my OddEvenItem to print CSS classes based on a 1
> index at all? Should I override onComponentTag instead of changing the
> index to 1 in my newItem-method?
>
> Thanks für help!
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: thorsten.schoen...@am-soft.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to