Editable grid

Certified Senior Developer

I am having a editable grid in that  I am adding a rows and in sometime I deleted some of the rows then the values depending upon it needs to be updated

For eg. I am having a field in editable grid called marks and total. If I deleted a one row(marks) Then the total needs to be updated after deleting

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    in reply to Harshit Bumb (Appyzie)

    yes but this is different scenario I am asking

  • 0
    Certified Lead Developer
    in reply to Udhaya Kumar M

    This is same code used in the thread harshit mentioned I have just added a delete button it is handling the scenario.

    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"),
          a!gridLayoutHeaderCell(label: "")
        },
        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!textField(readOnly: 1)
              }
            ),
            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
                ),
                a!richTextDisplayField(
                  value: a!richTextIcon(
                    icon: "times",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!gridData,
                        remove(local!gridData, fv!index)
                      )
                    )
                  )
                )
              }
            )
          )
        )
      )
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Udhaya Kumar M

    This is same code used in the thread harshit mentioned I have just added a delete button it is handling the scenario.

    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"),
          a!gridLayoutHeaderCell(label: "")
        },
        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!textField(readOnly: 1)
              }
            ),
            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
                ),
                a!richTextDisplayField(
                  value: a!richTextIcon(
                    icon: "times",
                    link: a!dynamicLink(
                      saveInto: a!save(
                        local!gridData,
                        remove(local!gridData, fv!index)
                      )
                    )
                  )
                )
              }
            )
          )
        )
      )
    )

Children
No Data