Hello,
I am new to Appian and have a requirement to create grid columns dynamically based on the data available in the database. I need to generate these columns dynamically according to the available data.Thank You..!!
Discussion posts and replies are publicly visible
Hello Prasanta Paul
Thanks for the reply.
I have already fetched the data into the local variable like this:
How can I use this data in a grid directly with foreach?
a!gridField( label: "", labelPosition: "ABOVE", data: local!name, columns: { a!gridColumn( label: "First Name", sortField: local!name['recordType!GT CustomerDetails.fields.firstName'], value: fv!row['recordType!GT CustomerDetails.fields.firstName'] ), a!gridColumn( label: "Last Name", sortField: local!name['recordType!GT CustomerDetails.fields.lastName'], value: fv!row['recordType!GT CustomerDetails.fields.lastName'] ) }, pageSize: 16 ) } )
Here, I want the columns to be displayed dynamically. If there are 10 data fields, then 10 columns should be displayed dynamically.
a!localVariables( local!items:rule!GT_firstName(), a!gridLayout( label: "Customer", headerCells: { a!gridLayoutHeaderCell(label: "First Name"), a!gridLayoutHeaderCell(label: "Gender"), }, rows: a!forEach( items: local!items, expression: { a!gridRowLayout( contents: { a!textField( value: fv!item['recordType!GT CustomerDetails.fields.firstName'], ), a!textField( value: fv!item['recordType!GT CustomerDetails.fields.gender'], ) } ) }, ) ) )