Change color of repeating section based on count - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Change color of repeating section based on count

Last post 08-23-2011 11:37 AM by Lockdown. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-19-2011 07:25 AM

    • Big E
    • Top 500 Contributor
      Male
    • Joined on 02-18-2009
    • Alabama
    • Posts 35

    Change color of repeating section based on count

    I have a project managment form that I built that has a repeating task section with a repeating subtask section underneath.  I use the count function to return a number for each task item.  All is working fine.  What I would like to do is change the color of the top level repeating section which in this case is "Task" based on the row count.

    For example, task 1 = blue, task 2 = red, task 3 = blue, task 4 = red.  Pretty much, same color for every other insert.  I can do this by adding a condition based on the count.  However, this is a terrible way of getting this to work.  Not efficient at all.

    Any suggestions?

    Filed under:
  • 08-21-2011 12:39 PM In reply to

    Re: Change color of repeating section based on count

    How about just using the xpath "mod" operator? Something like number(position() mod 2) will return 0 or 1 and then you can do conditional formatting on that if it's 0.

    Patrick Halstead
    Project Manager at Qdabra
  • 08-23-2011 11:08 AM In reply to

    • Big E
    • Top 500 Contributor
      Male
    • Joined on 02-18-2009
    • Alabama
    • Posts 35

    Re: Change color of repeating section based on count

     Could you give me an example of this?  Never used that before.

  • 08-23-2011 11:37 AM In reply to

    Re: Change color of repeating section based on count

    Here is what you gotta do:

    Add 2 conditions to the conditional formatting section of your repeating section. Use these two equations. The Mod operator (mod, %) really just gives you a remainder as an output.

    5 mod 2 = 1       5/2 has a remainder of 1

    6 mod 3 = 0       6/3 has a remainder of 0

    Use these two equations.

    1. number(position() mod 2) = 0 - then set the shading to what ever color you want.

    2. number(position() mod 2) = 1 - then set the shading to what ever color you want.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.