Repeating table with alternate row color - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Repeating table with alternate row color

Last post 09-30-2011 11:51 AM by Lockdown. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 03-11-2009 08:36 PM

    Repeating table with alternate row color

    Hi all,

    I am new Infopath. I am creating a repeating table programatically.Is it possible to set the alternate row color for the repeating table?

     

    Cheers
    Murali
  • 03-11-2009 10:30 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Repeating table with alternate row color

  • 03-12-2009 03:25 AM In reply to

    Re: Repeating table with alternate row color

    Hi Anuma,

    Thanks for your reply.But i want to set the row colour programmatically not from in the design mode?

    How to do it ?

     

     

    Cheers
    Murali
  • 04-30-2009 09:56 AM In reply to

    Re: Repeating table with alternate row color

    There is no way to set row colors using just code and anything you could do to color alternating rows with code would be more complicated than not using code.

    I would recommend using conditional formatting with two conditions:

    position() mod 2 = 1  - color for odd rows

    position() mod 2 = 0  - color for even rows

    You'll also need to specify the backround color on textboxes, etc, to "No color" in order to make them transparent.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-27-2010 08:43 AM In reply to

    Re: Repeating table with alternate row color

     

    I am trying to change the alternat color of rows of infopath repeating table.  I tried this above thing, no use for me.I think the way i did was wrong.

    can you please explain it little clear

  • 09-20-2011 08:58 AM In reply to

    Re: Repeating table with alternate row color

    Hi!

    This sound very promising, and I would love to make alternate row colors work on my tables, as some of them are painfully long.

     I selected the repeating table, created two formatting rules on it, where each of them had one of the conditions you wrote. I just pasted it into the condition-builder, not using a function builder, it was not available there.

     

    So the condition builder said:
    ----------------------------------------------------

    Run the rule when this condition is true:

    The expression   position() mod 2 = 1

    ------------------------------------------------------

    Then i put background color in the Rules panel, Formatting section.

     Any pointers to what I am doing wrong? I am using Infopath 2010.

    Thank you!

  • 09-20-2011 09:09 AM In reply to

    Re: Repeating table with alternate row color

    Could you attach your XSN to this thread?  Or if you don't want to publically share your form, try this in a brand new XSN and attach that?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-20-2011 09:49 AM In reply to

    Re: Repeating table with alternate row color

    Hi

    I figured it out on my own! Wow, these are the things that will make it much better in my forms. I thought it was odd it was not part of the Design-tab to set it up actually.

    I did not attach XSN as I am not sure what it is. File format probably, so you get the whole project. But I attached a picture that explaines where I went wrong, and how it is supposed to be.

    What I left out was to attach the condition to the table properly, it was just dangling in the air.

    Thanks for the code snippet :D

     ------------------------------------------

    Rats, I cannot add the image.

    Short recipe on how to do it right, from someone who just learned it:

    Set up 2 formatting rules, EvenRows and OddRows, on the repeating table (MyTable, often called groupX auto. The icon is a open folder with blue ball on it)

    EvenRows
    Condition: MyTable=position() mod 2 =1
    Rule type: Formatting
    Formatting (put on a background color)

    OddRows
    Condition: MyTable=position() mod 2 = 0
    Rule type: Formatting
    Formatting (put on a different background color)

    What I did wrong is that I set the condition to be
    Condition: position() mod 2 =1
    This is not enough.

    When setting up the condition, choose "Select a field or group..." not "The expression". 
    Then select "is equal to". Next combo, select "Use a formula", then you get to validate the snippet in the formula builder. In the builder, you paste in the code snippet "position() mod 2 = 0" - part.
    This is where I took a wrong turn. Hope this helps for others.

  • 09-21-2011 12:06 AM In reply to

    Re: Repeating table with alternate row color

    Beautiful!

    Such a coincidence too. I created the same sample last week. Too bad the cells can't have a background color when they're in a table. :)

    Cheers,

    Patrick Halstead
    Project Manager at Qdabra
  • 09-21-2011 08:55 AM In reply to

    Re: Repeating table with alternate row color

    Thank you :)

     I have discovered another pickle with this, after testing step by step why it would not take on my existing tables (the sample above I made in a different project just quickly).

    My project is quite large with 19 views (for nav purposes), and several tables in each. And quite a lot of complexity in each view, set on tables. Which I would not like to re-do..

    Pickle:
    - The format rule background-color is prioritized under property settings on rows, such as Shading (my testing is clear here)
    - So the row needs to have init state properties, i.e. no color set + no "no fill" set, as repeating tables are initially when put in
    - how do I set this init state, when I have already set background color on rows on my tables?? Word has a "clear formatting" that would be super-handy here..

    On TableTools>Layout>Borders there is a tab called Shading. And a radio button called "No color". Got my hopes up, but did not come through. So what now?

     

  • 09-30-2011 11:51 AM In reply to

    Re: Repeating table with alternate row color

    Patrick Halstead:

    Beautiful!

    Such a coincidence too. I created the same sample last week. Too bad the cells can't have a background color when they're in a table. :)

    Cheers,

    They can! Just use a dummy section inside the cell of a table. Set all padding to zero for that cell as well as the margins to zero in the section. You also need to remove the border on the section even though you cannot tell it is there unless you have a different color background..

    It seems to be defaulted to a white border, so make sure you click "none" and it will shift your section to fit perfectly inside the cell.

    You can then conditionally format that section and make all the cells of a table different colors!

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