Alternate Row Colors of Nested Repeating Group

Hello,

I am familiar with the common method of using modulo 2 is 0 to alternate the background color of RG rows on a repeating group however I have not been able to figure out how to make this work on nested repeating groups in the sense that I would like each row of the main rg + any visible child elements to alternate.

To give an example, lets imagine that I have a list of 3 numbers starting at 1 and ranging to 3 and each of these numbers have 3 numbers nested inside that range from 1 to 3
we need a count of all items and visible child items
If current index is > than any parents with visible children then we need to sum the count of each and do module 2 is 0 on this number to determine the color of the row. I illustrated it using a table below.

  • 1
    • 1 = 2
    • 2 = 3
    • 3 = 4
  • 2 or 5
    • 1 ( 3 or 6)
    • 2 (4 or 7)
    • 3 (5 or 8)
  • 3 or 6 or 9
    • 1 (4 or 7 or 10)
    • 2 (5 or 8 or 11)
    • 3 (6 or 9 or 12)
      Anyone able to figure this out? all help is greatly appreciated. Thanks!

I figured it out and thought I would share my solution for anyone else that may be wondering how to do this, the solution can be confusing but it is working…

I am using two plugins (if-then value and RG Data/Extractor) however the if-then value could be replaced with an input to store the index. Could possibly use custom states to replace rg data / exractor but have not attempted. Can not provide a demo app due to use of plugins but will try my best to display everything below.

RG Extractor in Parent RG:
display 1 (if child rows are not visible)
display a sum of visible child rows + childs visible child rows + 1 (if child rows are visible)
the (+1) is to account for the parent row.
image image image

RG Extractor in nested RG:
imageimage
imageimage

This is all the setup required, now we will set the conditions on (parent rg1) (nested rg 2) and double nested (rg 3)

Parent RG Condition:
image image

Child RG 1 (Nested 1 Layer in):
image image image

Child RG2 (Nested 2 Layers in)
imageimage
image
Nested Arbitrary Text Values Below:

Nested Arbitrary Text 1:
image

Nested Arbitrary Text 2:
image

This results in the following:

1 Like

@coty this is awesome!

I was breaking my head over this yesterday with no success.
Do you think you could upload this to Atomic Fusion? I’d love to share this with the community there.

@atomicfusion I am not familiar with your platform but you can post this solution under your name if you want to. also this solution could be refined quite a bit which would simplify everything and also be more efficent. Let me take another look at this here today and I will post a new solution that will be alot easier to follow.

1 Like

@atomicfusion I refactored things to make it much easier to understand, here is how its done…

RG Data / RG Extractor - This plugin generates dynamic lists of data from repeating groups and consists of two elements. (RG Data & RG Extractor)

Typically in a non nested RG the " rg data" element would be placed outside of the RG and “rg extractor” would be placed inside however for nested RG’s the setup is a little different, since we need data from the main RG and the nested we will use 2 instances of this plugin.

Lets setup the one that goes outside of the RG first…
image

  1. the first picture relates to RG data which can be placed outside of the RG anywhere on the page.
  2. The second picture relates to rg extractor which needs to be placed inside the RG
  3. We are using a boolean(yes/no) converted to number to diplay either 1 or a count of all visible children +1 (the 1 is simply to account for the current row)

Now lets setup rg data / extractor for the nested RG:

  1. This requires us to add an input element to the (PARENT) rg that will be the parents current index.
  2. This value must be used in the RG Extractor name field so that RG data can distinguish between each sub list. Basically a list of lists.
  3. Be sure to place RG Data in the Nested RG and RG extractor in the parent RG rather then outside of the RG as we did for the first setup.
    See Pictures below:
    imageimage

We can now access these lists, the Parent RG data can be accessed from anywhere outside or inside the RG however the child list can only be accessed from inside each parent RG. see the picture below to visualize the data we have generated and you will see the top list first number is 5 which is how many items are in this grouping, we can also see child list displays 3 which equals itself + children
image

With this information we can now figure out what each cells number should be, I am using inputs to hold some values to make things more simple to understand.
Parent RG Contains 2 inputs (not including one used for RG Extractor)
Child 1 RG Contains 3 inputs:
Child 2 RG Contains 1 Input

Parent RG Inputs:
Input 1:
image

Input 2:
image

Child 1 Inputs:
Input 1:
image

Input 2:
image

Input 3
image

Child 2 Input:
image

All of this should be much easier to understand and produces the following:

1 Like