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
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() ) ) ) ) ) ) ) ) ) } ) )
type of input is integer array ?
No, It is just integer.
umm that should not be the case. I want to pass value in array.. and suppose the array will be like this : {21,26,27,28,30,36,1,2,5,199,200}..Then it will not work
In this blog post
https://appian.rocks/2022/09/19/building-customisable-components/
I describe how to turn a list into a two-dimensional matrix. Then you can just run two nested foreach() loops to output the values in any way you like.
Hi Stefan, I wrote this code to print things in above formata!localVariables( local!array:{{1,2,3},{4,77,88},{77,88}}, { a!forEach( items: local!array, expression: a!sectionLayout(divider: "BELOW",contents: {a!forEach( items: fv!item, expression: a!richTextDisplayField( value: a!richTextItem( text: fv!item ) ) )}) ) })But it is giving output like this
Sure. Appian automatically merges your values into a one-dimensional list.
what's the way to make it 2 dimensional ?
The code I shared in my blog post.
Thank you so much stefan. It helped me a lot..