Question relate to array

Hi All,

I've a question relate to array.

I've a array like {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}

Want to print in row and column for mat like this:


1     2     3      4       5

6     7     8      9       10

11   12   13    14     15

16   17   18




Currently we have 18 items. It can be 25 items, 100 items, 200 items and so on...

I print all items in rich text in column layout.


  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    a!localVariables(
      local!array: enumerate(ri!input) + 1,
      local!cardsPerRow: 5,
      local!numOfRows: tointeger(
        ceiling(
          count(local!array) / local!cardsPerRow,
          .5
        )
      ),
     a!columnLayout(
          contents: {
            a!forEach(
              items: enumerate(local!numOfRows) + 1,
              expression: a!localVariables(
                local!rowIndex: fv!index,
                a!columnsLayout(
                  columns: a!forEach(
                    items: enumerate(local!cardsPerRow) + 1,
                    expression: a!localVariables(
                      local!colIndex: local!cardsPerRow * local!rowIndex - local!cardsPerRow + fv!index,
                      local!entityIdForColIndex: index(local!array, local!colIndex, null()),
                      a!columnLayout(
                        contents: a!richTextDisplayField(
                          value: a!richTextItem(
                            text: index(
                              local!array,
                              local!entityIdForColIndex,
                              null()
                            )
                          )
                        )
                      )
                    )
                  )
                )
              )
            )
          }
        )
      
    )


    I think the above code will work dynamically for your requirement. 

Reply
  • 0
    Certified Lead Developer

    a!localVariables(
      local!array: enumerate(ri!input) + 1,
      local!cardsPerRow: 5,
      local!numOfRows: tointeger(
        ceiling(
          count(local!array) / local!cardsPerRow,
          .5
        )
      ),
     a!columnLayout(
          contents: {
            a!forEach(
              items: enumerate(local!numOfRows) + 1,
              expression: a!localVariables(
                local!rowIndex: fv!index,
                a!columnsLayout(
                  columns: a!forEach(
                    items: enumerate(local!cardsPerRow) + 1,
                    expression: a!localVariables(
                      local!colIndex: local!cardsPerRow * local!rowIndex - local!cardsPerRow + fv!index,
                      local!entityIdForColIndex: index(local!array, local!colIndex, null()),
                      a!columnLayout(
                        contents: a!richTextDisplayField(
                          value: a!richTextItem(
                            text: index(
                              local!array,
                              local!entityIdForColIndex,
                              null()
                            )
                          )
                        )
                      )
                    )
                  )
                )
              )
            )
          }
        )
      
    )


    I think the above code will work dynamically for your requirement. 

Children