Repeating Table – set color for alternative rows and auto number the rows

Set color for alternative rows:

Logic behind : Odd number of rows(1,3,5,7..) when divided by 2 will return the remainder 1  and even number of rows(2,4,6,8..) when divided by 2 will return the remainder 0. To find the remainder, we use mod(modulo) operator. To find whether the row is odd number or even number, we can use position() in infopath.

  • Go to Home->Manage rules
  • In fields pane, select the group containing repeating fields and add formatting rule
  • Under condition, click on None and select “The expression” in first drop down
  • To color the odd rows, enter the expression as position() mod 2 > 0 or position() mod 2 = 1
  • Under Formatting, select the color that you would like to apply in Shading(bucket symbol)

Color alternative rows

  • Click on Home->Preview to see the result

Auto number repeating table rows:

  • To auto generate number in SNO inside repeating table, right click on SNO ->Text Box Properties
  • Under Default values, click on fx and insert the formula, count(../preceding-sibling::my:group2) + 1 and click ok

  • You can also use position() instead of the above formula but this will not be supported in InfoPath 2013 text box. However, it can be used in Calculated value in InfoPath 2013. Right click the SNO ->Change Control->Calculated Value and enter position() in XPath

  • Click on Home -> Preview to see the result.

 

Advertisements

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s