Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Alternating row color for details row when using group
bchicos
<p>Hello, </p><p> </p><p>I am trying to create alternating row colors for my 'details' rows. My report also is grouped. I would like the first row of each group to be grey and then alternate. </p><p> </p><p>The only solution I found for doing this however is to create a 'Highlight' for the details row that uses the below expression. </p><p> </p><p>row.__rownum % 2 equals 0</p><p> </p><p>This creates alternating colors, but as you can see in the screenshot it ignores the grouping and just cares about the row number. Is there any expression that will give me the row index which starts at 0 for each new group?</p><p> </p><p>I'm a bit of a newbie on report design so appreciate the help. Thanks. </p>
Find more posts tagged with
Comments
garberfc
<p>I'm a newbie as well, but I have a thought that may get you closer to your solution.</p><p> </p><div>Instead of basing the on/off on the row number, can you incorporate a report scoped counter? The counter would get incremented for each detail row and highlighting would be based on counter % 2. Each time a 'group' row is emitted the counter could be reset to zero.</div><div> </div><div>I'm not sure if it's possible or how to implement such a solution, but I'm hoping others on the forum here can chime in...</div><div> </div><div>Good luck,</div><div>F</div><div><div><div style="margin-left:12px;"><div style="font-family:'MS Shell Dlg 2';color:#000000;font-size:9pt;"> </div><div style="color:rgb(0,0,0);font-size:9pt;"> </div></div></div></div>
garberfc
<p>I messed with the designer and got the solution. Below is the code:</p><pre class="_prettyXprint _lang-xml">On the grouping section:<method name="onCreate"><![CDATA[ counter = 0;]]></method>On the detail section:<detail> <row id="52"> <method name="onCreate"><![CDATA[ counter = counter + 1; if (counter % 2 == 0) { this.getStyle( ).backgroundColor = "#AAAAAA"; } else { this.getStyle( ).backgroundColor = "#EEEEEE"; }]]></method></pre>
bchicos
<p>That worked. Thanks for the scripting idea. </p>