I am setting styles on CellList items on an individual basis using:
cellList.getRowElement(0).addClassName("style-name-A");
cellList.getRowElement(1).addClassName("style-name-B");
This is reflected when I run the application. But when I click any row item all the items lose these styles and revert to the standard style of the CellList (as defined in my CellListResources css file). How can I stop this behaviour?
I am adding items to the CellList via a ListDataProvider; using a subclass of MultiSelectionModel to handle selections and have passed in my own CellListResources to the CellList constructor to define the base styles.
This happens because the selection re-renders the row, therefore loosing any changes you would have made to this element.
The workaround I found for this is to handle it at individual cell level.
In practice I wrap each of my cells into a "StyleAwareCellDecorator" which creates a span around with a given style. I then decides what style to apply based on some logic. It could be based on the context.getIndex() in your case.
With this facility in place you could replace your code with:
And let say store that in a Map