Interface

Certified Senior Developer

I am using a editable grid in that there are six columns (column1,2,3,4,5,6) after adding rows to that columns I want add a row at the end for column3,4,5,6 only for calculating the total value. Is that possible in editable grid

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Something like this you can build.

    a!localVariables(
      local!gridData: a!map(
        col1: "",
        col2: "",
        col3: "",
        col4: "",
        col5: "",
        col6: ""
      ),
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Col1"),
          a!gridLayoutHeaderCell(label: "Col2"),
          a!gridLayoutHeaderCell(label: "Col3"),
          a!gridLayoutHeaderCell(label: "Col4"),
          a!gridLayoutHeaderCell(label: "Col5"),
          a!gridLayoutHeaderCell(label: "Col6")
        },
        addRowLink: a!dynamicLink(
          label: "Add",
          saveInto: a!save(
            local!gridData,
            append(
              local!gridData,
              a!map(
                col1: "",
                col2: "",
                col3: "",
                col4: "",
                col5: "",
                col6: ""
              )
            )
          )
        ),
        rows: a!forEach(
          items: local!gridData,
          expression: if(
            fv!index = count(local!gridData),
            a!gridRowLayout(
              contents: {
                a!textField(readOnly: true()),
                a!textField(readOnly: true()),
                a!textField(readOnly: true(), value: "Total"),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col4", {}))
                ),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col5", {}))
                ),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col6", {}))
                )
              }
            ),
            a!gridRowLayout(
              contents: {
                a!textField(
                  value: fv!item.col1,
                  saveInto: fv!item.col1
                ),
                a!textField(
                  value: fv!item.col2,
                  saveInto: fv!item.col2
                ),
                a!textField(
                  value: fv!item.col3,
                  saveInto: fv!item.col3
                ),
                a!textField(
                  value: fv!item.col4,
                  saveInto: fv!item.col4
                ),
                a!textField(
                  value: fv!item.col5,
                  saveInto: fv!item.col5
                ),
                a!textField(
                  value: fv!item.col6,
                  saveInto: fv!item.col6
                )
              }
            )
          )
        )
      )
    )

Reply
  • 0
    Certified Senior Developer

    Something like this you can build.

    a!localVariables(
      local!gridData: a!map(
        col1: "",
        col2: "",
        col3: "",
        col4: "",
        col5: "",
        col6: ""
      ),
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Col1"),
          a!gridLayoutHeaderCell(label: "Col2"),
          a!gridLayoutHeaderCell(label: "Col3"),
          a!gridLayoutHeaderCell(label: "Col4"),
          a!gridLayoutHeaderCell(label: "Col5"),
          a!gridLayoutHeaderCell(label: "Col6")
        },
        addRowLink: a!dynamicLink(
          label: "Add",
          saveInto: a!save(
            local!gridData,
            append(
              local!gridData,
              a!map(
                col1: "",
                col2: "",
                col3: "",
                col4: "",
                col5: "",
                col6: ""
              )
            )
          )
        ),
        rows: a!forEach(
          items: local!gridData,
          expression: if(
            fv!index = count(local!gridData),
            a!gridRowLayout(
              contents: {
                a!textField(readOnly: true()),
                a!textField(readOnly: true()),
                a!textField(readOnly: true(), value: "Total"),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col4", {}))
                ),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col5", {}))
                ),
                a!textField(
                  readOnly: true(),
                  value: sum(index(local!gridData, "col6", {}))
                )
              }
            ),
            a!gridRowLayout(
              contents: {
                a!textField(
                  value: fv!item.col1,
                  saveInto: fv!item.col1
                ),
                a!textField(
                  value: fv!item.col2,
                  saveInto: fv!item.col2
                ),
                a!textField(
                  value: fv!item.col3,
                  saveInto: fv!item.col3
                ),
                a!textField(
                  value: fv!item.col4,
                  saveInto: fv!item.col4
                ),
                a!textField(
                  value: fv!item.col5,
                  saveInto: fv!item.col5
                ),
                a!textField(
                  value: fv!item.col6,
                  saveInto: fv!item.col6
                )
              }
            )
          )
        )
      )
    )

Children