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)
- 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.
Hi
Dose not work in my code when used position () for different color for odd and even all color for example return blue. ( in sharepoint browser)
Please help me
Thank you
LikeLike
Hi Baharak,
Please note that position() is not supported in browser based forms. Instead use (count(preceding-sibling::*) +1) mod 2 > 0 in the expression and let me know if you have any queries
LikeLike