Observation: Alternate row color changes in custom style [message #1746648] |
Wed, 02 November 2016 09:37  |
Eclipse User |
|
|
|
When we apply the custom style to a table, then while scrolling the table changes the ODD and EVEN table row color.
Take the example Classic Examples -> Styling -> Custom styling of Specific cells.
Scroll the nattable one row at a time, and inspect the ODD/EVEN numbered row colors.
it changes again and again.
Is it a desired behaviour or its a bug?
If its a bug then we do the following changes in ColumnOverrideLabelAccumulator, then it works fine.
if(rowPosition%2==0)
configLabels.addLabel("EVEN_BODY");
else
configLabels.addLabel("ODD_BODY");
|
|
|
Re: Observation: Alternate row color changes in custom style [message #1746664 is a reply to message #1746648] |
Wed, 02 November 2016 11:44  |
Eclipse User |
|
|
|
Quote:Is it a desired behaviour or its a bug?
It is neither a desired behavior nor is it a bug. It is a wrong configuration on your side that also exists in some of the NatTable examples (so no blame, just a hint).
The issue is hidden in the creation of the AlternatingRowConfigLabelAccumulator. If you create it with a layer it is able to translate the row position to the row index. If you follow one of our examples that creates the GridLayer yourself and sets the layers afterwards, the DefaultGridLayerConfiguration will initialize the AlternatingRowConfigLabelAccumulator with null as parameter, which leads to the usage of the row position. And that changes on scrolling which leads to the changing background colors.
If you set the body layer stack yourself to the GridLayer AFTER the GridLayer is initialized, you need to set the config label accumulator for the alternating rows again with the correct body layer reference.
setConfigLabelAccumulatorForRegion(
GridRegion.BODY,
new AlternatingRowConfigLabelAccumulator(bodyLayer));
|
|
|
Powered by
FUDForum. Page generated in 5.17279 seconds