a!gridrowlayout in a!foreach

Certified Senior Developer

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

Parents Reply
  • 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).

Children
  • 0
    Certified Senior Developer
    in reply to Peter Lewis

    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
    )
    }
    )
    )
    )

  • 0
    Appian Employee
    in reply to om786

    Ok a few suggestions:

    • In your local!counts variable at the top, you should define that variable as a complex type and not just as a list of strings. Do you have a CDT or Record that you could use for that variable that has information for your question / option / correct options? Even if you don't, I'd suggest using a map, which would allow you to save any data you need to. Here's how you could construct it with a map:

      local!counts: repeat(local!count, a!map()),

    • You also don't have anything that's actually saving in your text fields. You should include code like this to actually save the data:

      saveInto: fv!item.question,
      value: fv!item.question,