Alternating background color in details section

I am attempting to use the alternating color feature in the details section for a listing of data, where you can alternate the color based on a condition.  What my client wants is to have the color change based on the first letter of the names, which are in alphabetical order.  At first I thought this was simple: I just put an if statement cycling through, using every other letter of the alphabet.  This worked fabulously until I realized that if there were no names for a particular letter (such as Q), that it would not alternate in that instance - the "P" and the "R" would both be white.  Does anyone have a solution to this? Is there a way I can change it based on everytime the first letter changes? Thanks in advance!

This should do the trick for you...
Global NumberVar x := IF RecordNumber = 1 THEN 1 ELSE x;
Global StringVar l := IF RecordNumber = 1 THEN LEFT({TableName.LastName}, 1) ELSE l;
x := IF l = LEFT({TableName.LastName}, 1) THEN x ELSE x + 1;
l := LEFT({TableName.LastName}, 1);
IF x MOD 2 = 1 THEN crSilver ELSE crNoColor;
HTH,
Jason

Similar Messages

  • Alternating Background color for Detail Records

    Post Author: jbecker
    CA Forum: Formula
    I have found other posts concerning thing similar to this but not quite the same.  I have an 8.5 report that needs to have everyother record in the detail section to be a different color.  The problem is that it is counting all the records not the ones that are filtered out and displayed in the details section.  I have played around with the "If RecordNumber Mod 2 = 0 Then crSilver Else crNoColor" formula but it doesn't work right.  I am thinking that my formula needs to be applied last but how do I accomplish that?  Any and all help will be greatly appreciated. Thanks,Jerry

    Post Author: jbecker
    CA Forum: Formula
    What I mean, excuse my newbiness, is the formula is in the formatting of the detail section which is being applied on the first pass. The bottom of the report shows the record count on the first pass and the report is showing about half as many.  Does that make sense? So my question is, how do I use your suggestion?  I am somewhat of an inexperienced user and need all the help someone can offer.
    Thanks,
    Jerry

  • Group Footer Alternating Background Color

    I have an alternating background color on my GF2, which works correctly using the code below in the section expert.  However when I add a new suppressed group (GH3/GF3) to the report, the alternating is not correct as it may skip a few instances of GF2, and then color 5 instances of GF2 in a row, etc.  GF2 is the only section that is not suppressed in the report.
    How do I correct this?
    if groupNumber mod 2 = 0 then color(235,235,235) else crNoColor

    This is expected behavior.
    Suppressed group does not mean it is not counted for GroupNumber function.
    I would suggest to modify your formula as following:
    numbervar a:=a+1;
    if a mod 2 = 0 then color(235,235,235) else crNoColor

  • Alternating background color for BC4J DataTable?

    I am surprised that I couldn't see an example of this anywhere. The documentation in the bc4j.css indicates that it is possible to "enable the alternating colors feature for the HTML Table Control", I would think this is just a checkbox somewhere. Can someone please point me to it?
    Thanks,
    Mike

    We accomplished this but by changing the DataTableComponent.jsp.
    I dont think there is any checkbox which will enable this feature.
    Thanks
    Sashi

  • Want robust solution for alternating row color, resetting every group

    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 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

  • How can I create an alt background color for items in a jlistbox or jtree

    What I'm looking to do is have a white background for say items 1,3,5, etc. and a light yellow background for items 2,4,6, etc. I was wondering how can I set an alternative background color on items in a JTree or a JList

    Use a cell renderer:
    import java.awt.*;
    import javax.swing.*;
    public class ListAlternating extends JFrame
         public ListAlternating()
              String[] items = {"one", "two", "three", "four", "five", "six", "seven"};
              JList list = new JList( items );
              list.setVisibleRowCount(5);
              list.setCellRenderer( new MyCellRenderer() );
              JScrollPane scrollPane = new JScrollPane( list );
              getContentPane().add( scrollPane );
         public static void main(String[] args)
              ListAlternating frame = new ListAlternating();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
         class MyCellRenderer extends DefaultListCellRenderer
              public Component getListCellRendererComponent(
                   JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
                   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                   if (!isSelected)
                        setBackground(index % 2 == 0 ? list.getBackground() : Color.LIGHT_GRAY);
                   return this;
    }

  • Alternating Color Subreport details

    I've created a subreport with detail lines that can be suppressed if the value of my database field is zero.  So on some reports I could have 7 lines.. and some I could have three (for example) depending on the data.  I have to make this table an alternating color table. So if the first line has a white background, the next line needs to have a silver background.. if the line before a line has a silver background.. that line needs to have a while background.
    Example of report with 5 detail lines showing:
    White
    Silver
    White
    Silver
    White
    Example with 8 detail lines showing:
    White
    Silver
    White
    Silver
    White
    Silver
    White
    Silver
    There are only 10 detail lines available and the first one is always white. I've been trying to write a formula in the background color properties in my section expert for each detail line that would do this for me.. I was going for something like:
    If previous value is crWhite then
    formula = crSilver
    else
    formula = crWhite
    end if
    I know this is wrong because I can't find a function that will do it for me. Does anyone know a simple way to do this?
    Thanks!

    Is this in a detail format or group header/footer?  Is the format conditionally suppressed?  These will change the formula.  If it's in a group header/footer, use (basic syntax):
    global toggleColor as number
    toggleColor = 1 - toggleColor
    if toggleColor = 0 then
      formula = crSilver
    else
      formula = crWhite
    end if
    If records are conditionally suppressed, use the formula above, but add an IF statement around the toggleColor = toggleColor - 1 line with the condition "NOT (whatever your suppression formula is)".
    HTH,
    Carl

  • How to print alternative colors in detail records in BI publisher?

    Hi,
    i have child or detail records. But i want to print them first record in red color,then second record in green color. Again third record color again in red color and fourth record again in green color.
    Thanks,
    lax

    Have two form fields after the grouping form field and use the following code in the first conditional form field:
    <?if@row:number(position() mod 2)=0?><?attribute@incontext:background-color;'red'?><?end if?>
    Include this in the second conditional format field.
    <?if@row:number(position() mod 2)!=0?><?attribute@incontext:background-color;'green'?><?end if?>
    Thanks,
    Bipuser

  • Section Header Text Background Color

    Hi have a catalog that has a running section header that will be placed over a black graphic the width of the page header.  I would like to have a white background box appear the length of the header section text, but not be the full length of the text box defined on the master pages for the header.  I would like to do this in an automated fashion rather than manual placing the graphic around the header text on each page.  It won't work to place a white box under the text as it is part of the background already being a master page item, or am I missing something.  In brief can I have a background color that dynamically adjusts to the length of a text string?
    Thanks,
    Dave

    If that text has a character style (or if it doesn't give it one) make the character style include an underline, then make that underline really thick and give it a baseline shift.  The same technique is commonly used for highlighting.  There's a few other options you can play around with in the underline options too.

  • Background color change of detail pop up

    Hi,
    Please let me know the solution on how to change the detail pop up backgrond color.
    For more clarity on picture, path is, click on context menu--> details

    I am changing the lightblue  background (#F5F7F9) of the portal by downloading the theme
    and the unzip the portal.zip and then the default.properties:
    parPrtlBodyBackground=\#F5F7F9
    parDocumentBackgroundColor=\#F5F7F9
    Change the values to the required background color.
    Regards,
    Kai

  • Change background color of alternating rows in listview

    Hi all,
    Does anyone know how to change the background color of alternating rows in a listview in Visual Basic 2013?
    Best regards,
    Randy Boulter

    You can set the OwnerDraw property of the ListView to true and use the DrawItem event:
    Private Sub ListView1_DrawItem(sender As Object, e As DrawListViewItemEventArgs) Handles ListView1.DrawItem
    e.DrawDefault = True
    If (e.ItemIndex Mod 2) = 1 Then
    e.Item.BackColor = Color.FromArgb(220, 220, 220)
    e.Item.UseItemStyleForSubItems = True
    End If
    End Sub

  • Uitableview grouped style-is there any way to get section background color

    hi all,
    So far i have tried myself and searched everywhere but didnt figured out that is there any way to get section background colors different for each sections in grouped style tableview.
    If anyone has tried something to get such thing would really be helpful to me.
    Thanks,
    C.P.

    Have you tried this? [http://stackoverflow.com/questions/813068/uitableview-change-section-header-co lor]

  • UITableView section header: How to find out font size and background color

    Hi, does anyone know how to find out the default font and default background color(or image?) used in the section header of a tableView
    I'd like to create a view with the same background color/image and use the same font (with different color) used by the section header

    I don't think there are any getter methods for a section header. But I wouldn't be surprised if the header was an object. You might try setting some header text to a key string and searching recursively through all the subviews for objects that respond to a text message. It might help to also print the description of objects that don't respond to text. I haven't tried this yet, but will let you know if I get any useful results.
    I guess another approach would be to use viewForHeaderInSection to set the font and color to whatever you wanted. Then you wouldn't have any problem matching it.

  • Creating separation lines in the detail Section

    Hi All,
    I've got a database of 500 clients, and after listing out all the clients, i noticed it was difficult to follow the name across all the columns of information. 
    Is it possible to insert lines that span across the page after every entry?
    Thank You,
    Frank

    Your best bet is to use alternating highlights to separate data.
    Try this:
    1. SECTION EXPERT for your details section
    2. COLOR tab
    3. Custom Formula (x-2) for background color.
    4. enter formula without quotes "if recordnumber mod 2=0 then color (230,230,230) else nocolor"
    Colors can be replaced with whatever colors you want (replace "color (230,230,230)" with color name (crYellow) or with another RGB color combination.
    If you still prefer lines, you can try this:
    1. Insert section below on your details section.
    2. Add a line that spans the report.
    3. Resize your new section accordingly to fit the line.

  • How Do I Change the Background Color in Keynote?

    Hello! I am trying to change the background color in Keynote, I can see where I should be able to do this, however my computer does not let me. If I change the template (in the Fun template from the standard to the horizontal picture) it will let me change it only in the box rather than the entire template. I really want to keep the style, just not the orange color. Thanks!

    Ruth, the background in Fun is an image, not just a colour. For the templates without photo cutouts, you will need to select the template, go into the Inspector, choose Slide, select the Appearance tab, and then in the background section you can change the image. If you just want to change the colour, you can choose Tinted Image Fill in the dropdown menu, then click the colour box to control the tint.
    Unfortunately, changing the Photo template is much more difficult, since the "background" image is actually a cutout placed on the slide above the actual background. As far as I know, changing this image will require access to fairly sophisticated graphics programs, such as Photoshop. However, if you are using Keynote 3, an alternative would be to create an image mask that is similar in shape to the cutout, as this would produce the same effect (cutouts are not nearly as vital now that images can be masked to a shape).
    PowerMac G5   Mac OS X (10.4.4)  

Maybe you are looking for