Skip to main content
July 10, 2022
Question

Nested for each

  • July 10, 2022
  • 4 replies
  • 0 views

I have used nested foreach and cardlayout inside that

im getting the below output.

Below is my code.

a!columnsLayout(
                    marginBelow: "NONE",
                    spacing: "NONE",
                    columns: {
                      a!forEach(
                        items: 1+enumerate(2),                       
                        expression: {
                          a!localVariables(
                                                       
                        a!columnLayout(
                          contents: {
                            a!forEach(
                              items:1+enumerate(2),
                              expression:                 
                            a!cardLayout(
                              style: "INFO",
                            
                              contents: {
                                a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  align: "CENTER",
                                  value: a!richTextItem(                                   
                                    text:fv!item,
                                    color: "#1a1a00",
                                    size: "MEDIUM"
                                  ),                           )
                              },
                              height: "MEDIUM",
                              shape:"ROUNDED",
                             
                            ),
                         
                            )                           
                            },                         
                        )
                      ),a!columnLayout()
                    }
                  ),
                
                }
              )

Instead of printing 1 1

                              2  2

I want to display as 1 2

                                3 4.

how to achive this?

4 replies

harshitb6843
July 11, 2022

I hope this helps. 

a!columnsLayout(
  marginBelow: "NONE",
  spacing: "NONE",
  columns: {
    a!forEach(
      items: 1 + enumerate(2),
      expression: {
        a!localVariables(
          local!outerItem: fv!item,
          a!columnLayout(
            contents: {
              a!forEach(
                items: 1 + enumerate(2),
                expression: a!cardLayout(
                  style: "INFO",
                  contents: {
                    a!richTextDisplayField(
                      labelPosition: "COLLAPSED",
                      align: "CENTER",
                      value: a!richTextItem(
                        text: local!outerItem + (fv!index - 1) * 2,
                        color: "#1a1a00",
                        size: "MEDIUM"
                      ),
                      
                    )
                  },
                  height: "MEDIUM",
                  shape: "ROUNDED",
                  
                ),
                
              )
            },
            
          )
        ),
        a!columnLayout()
      }
    ),
    
  }
)

July 12, 2022

Thanks for the response. It will help..i will try

December 6, 2022

check this one out

a!localVariables(
local!number: 5,
local!row: 2,
local!remainder: local!number - quotient(local!number, local!row) * local!row,
if(
local!number<local!row,
null(),
a!columnsLayout(
marginBelow: "NONE",
spacing: "NONE",
columns: {
a!forEach(
items: 1 + enumerate(local!row),
expression: {
a!localVariables(
local!currenColumn: fv!item,
{
a!columnLayout(
contents: {
a!forEach(
items: 1 + if(
local!remainder = 0,
enumerate(quotient(local!number, local!row)),
enumerate(quotient(local!number, local!row) + 1)
),
expression: a!richTextDisplayField(
labelPosition: "COLLAPSED",
align: "CENTER",
value: if(
and(local!remainder <> 0, fv!isLast),
if(
contains(
enumerate(local!remainder) + 1,
local!currenColumn
),
index(
symmetricdifference(
enumerate(local!number) + 1,
enumerate(local!number -local!remainder) + 1
),
local!currenColumn,
null()
),
null()
),
local!currenColumn + (fv!index - 1) *local!row
),

)
)
},

),

}
),

}
),

}
)
)
)

csteward
December 6, 2022

Just to note, please utilize the Insert Code option here when posting snippets for readability: