I am trying to loop the multiple gridrowlayout of a editiable grid using a!foreach but not able to do it.
can i have some directions with possible code.
I required to flash multiple rows with loop on count of queries declared in the interface by the user
Discussion posts and replies are publicly visible
Please refer the below code.
a!localVariables( local!count, local!tech, local!gridData: if( a!isNullOrEmpty(local!count), null, a!forEach( items: enumerate(local!count) + 1, expression: { ques: "", option: "" } ) ), { a!textField( label: "Tech", value: local!tech, saveInto: local!tech ), a!textField( label: "Count", value: local!count, saveInto: local!count ), a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Question"), a!gridLayoutHeaderCell(label: "Options") }, rows: a!forEach( items: local!gridData, expression: a!gridRowLayout( contents: { a!textField( value: fv!item.ques, saveInto: fv!item.ques ), a!textField( value: fv!item.option, saveInto: fv!item.option ) } ) ) ) } )
Thanks for this support...
but now how can we use fv!index on this for each iteration..
Where you want to use fv!index and why?
Actually i want to enter multiple row enteries on a single shot of submit button. so in order to input the data in the DB, we have to run the different rows in the interface with the help of separate index no. so that it will help to create a unique identifier for each record in the DB.
Here i am using Questions & Answers table in Array CDT.
is you primary key column in Auto generated? If yes, then it is not required to assign any value to primary key column. If not, then on the click on submit button,into save into you can use writetoDatastoreentity function and in that you can use foreach loop.
I pretty much always use the submit button to handle any complex logic that you need before the form is submitted. As long as you can construct some kind of rule that adds the appropriate indexes you need, just add an a!save() on your submit button to then execute that rule and save it's results.
If you are looking for more specific guidance on handling indexing / manipulating data, I think we need a lot more information about what you are trying to do (preferably with an example or sample code).
Pls find the interface screenshot with code.
a!localVariables( local!tech, local!count: null, local!counts: repeat(local!count, " "), a!formLayout( label: "Questionare", contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!dropdownField( label: "Technology", labelPosition: "JUSTIFIED", placeholder: "--- Select a Value ---", choiceLabels: rule!MCS_GetTechnologyName().subname, choiceValues: rule!MCS_GetTechnologyName().subid, value: local!tech, saveInto: { a!save(local!tech, save!value), a!save(ri!Queries.subid, local!tech) }, searchDisplay: "AUTO", validations: {} ) } ), a!columnLayout( contents: { a!dropdownField( label: "Count of Queries", labelPosition: "JUSTIFIED", placeholder: "--- Select a Value ---", choiceLabels: cons!MCS_COUNTOFQUESTIONS, choiceValues: cons!MCS_COUNTOFQUESTIONS, value: local!count, saveInto: local!count, searchDisplay: "AUTO", required: true, validations: {} ) } ), a!columnLayout(contents: {}) } ), a!gridLayout( label: "Enter Questionnaire ", labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell(label: "Question"), a!gridLayoutHeaderCell(label: "Option Available"), a!gridLayoutHeaderCell(label: "Correct Option") }, columnConfigs: {}, rows: { a!forEach( items: local!counts, expression: a!gridRowLayout( contents: { a!textField( label: "Text", labelPosition: "ABOVE", saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ), a!textField( label: "Text", labelPosition: "ABOVE", saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ), a!textField( label: "Text", labelPosition: "ABOVE", saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ) } ) ) }, selectionSaveInto: {}, validations: {}, shadeAlternateRows: true )/*a!textField(*/ /*label: "Text",*/ /*labelPosition: "ABOVE",*/ /*saveInto: {},*/ /*refreshAfter: "UNFOCUS",*/ /*validations: {}*/ /*)*/ }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Submit", submit: true, style: "PRIMARY", loadingIndicator: true ) }, secondaryButtons: { a!buttonWidget( label: "Cancel", value: true, saveInto: {}, submit: true, style: "NORMAL", validate: false ) } ) ))
Ok a few suggestions: