on 04-08-2015 7:36 PM
I would like a solution for displaying an alternating row color for my detail rows that resets every group, so that row 1 is always gray.
Our Crystal designer provided this code to me:
@rowcnt formula, suppressed, placed in Detail row:
Shared numbervar rowcnt;
rowcnt := rowcnt + 1;
@resetrowcnt, suppressed, placed in Group row:
Shared numbervar rowcnt;
rowcnt := 0;
Formatting formula, placed in Color in Detail > Section Expert:
Shared numbervar rowcnt;
if Remainder(rowcnt, 2) <> 0 then
color(241,241,241)
else
crWhite
This was working fine for me.
However, it is suddenly not working in one of my reports.
The report does happen to have two groups (rowcount.png).
When the report is run, all rows are colored (rowcount02.png).
This report was previously working fine! I'm not sure what changed.
In any case... surely there must be standard code to do this very standard formatting.
I would be very grateful if someone could post some robust code to accomplish the following:
REPORT DATA IN DETAIL ROW, ALTERNATE ROW BANDING:
- Data in Detail row displays alternating row colors
- Odd rows are always shaded, even rows not
- Banding resets every group / does not continue pattern from previous group
REPORT DATA IN GROUP ROW, ALTERNATE ROW BANDING:
Some of our reports place row data in a group row (just the way it happened).
If you could also modify your code in this case.
Thank you!
Hi Vancouver,
-- Do you have any conditional suppress for detail section through Section Expert ? If so, you need to use the same condition for your accumulation formula.
-- Are you using 'rowcnt' variable name anywhere else in your report ? i.e. in any other formulas ?
Try to replace your formula with below formulas :
Reset formula :
Whileprintingrecords;
Numbervar cnt:=0;
row count Formula:
Whileprintingrecords;
Numbervar cnt:=cnt+1;
Detail section expert formula :
Whileprintingrecords;
Numbervar cnt;
if cnt mod 2 <> 0 Then Crred else crwhite
Thanks,
Sastry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, thanks for your responses. Yes the following is in Suppress for the Detail section:
not(OnFirstRecord) and
{HedgeDetails.StrategyID}=previous({HedgeDetails.StrategyID}) and
{HedgeDetails.DealID}=previous({HedgeDetails.DealID})
Where should I be placing this same argument then?
It's funny tho', this was all working fine a couple report versions ago, I have only been making cosmetic updates.
Thank you for your counsel. Unfortunately I cannot upload a report with data,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhilash/Sastry, since I'm going to switch to Sastry's formulas, could you please confirm correctness of the following. I can't actually run this report, I can only provide it to our London office, bit of a lag for testing.
@resetrowcnt:
Whileprintingrecords;
Numbervar cnt:=0;
@rowcnt:
Whileprintingrecords;
if {HedgeDetails.StrategyID} <> previous({HedgeDetails.StrategyID}) and
{HedgeDetails.DealID} <> previous({HedgeDetails.DealID}) then
(
Numbervar cnt:=cnt+1;
)
Details section (Suppress):
not(OnFirstRecord) and
{HedgeDetails.StrategyID}=previous({HedgeDetails.StrategyID}) and
{HedgeDetails.DealID}=previous({HedgeDetails.DealID})
Please note: Suppress checkbox is selected AND the above formula is entered.
Details section (Color):
Whileprintingrecords;
Numbervar cnt;
if cnt mod 2 <> 0 Then color(241,241,241) else crwhite
Hi,
What you've got in there is already a 'standard' way of doing this!
Like Sastry said, could you check if you've got conditional suppression logic for the details section?
Otherwise, would you be able to attach the report 'with saved data' for us to take a look at?
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.