how to add multiple rows on one click of add row link in editable grid?

In the editable grid I want to add 2 rows on click of add row link, please help me out how to add dt ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    This should be about as easy as utilizing the standard "add row link" and having it add 2 new entries to the dictionary storing your row data.  Without more detail it's hard to say exactly what you'll need.  What have you tried so far and had difficulty with?

    Quick example:

    a!localVariables(
      local!rows: {
        {
          name: "row 1",
          id: 1
        }
      },
      
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "name")
        },
        rows: a!forEach(
          local!rows,
          a!gridRowLayout(
            contents: {
              a!richTextDisplayField(
                value: fv!item.name
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label: "Add Row(s)",
          saveInto: {
            a!save(
              local!rows,
              append(
                local!rows,
                {
                  {
                    id: max(local!rows.id) + 1,
                    name: "row " & max(local!rows.id) + 1
                  },
                  {
                    id: max(local!rows.id) + 2,
                    name: "row " & max(local!rows.id) + 2
                  }
                }
              )
            )
          }
        )
      )
    )

Reply
  • 0
    Certified Lead Developer

    This should be about as easy as utilizing the standard "add row link" and having it add 2 new entries to the dictionary storing your row data.  Without more detail it's hard to say exactly what you'll need.  What have you tried so far and had difficulty with?

    Quick example:

    a!localVariables(
      local!rows: {
        {
          name: "row 1",
          id: 1
        }
      },
      
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "name")
        },
        rows: a!forEach(
          local!rows,
          a!gridRowLayout(
            contents: {
              a!richTextDisplayField(
                value: fv!item.name
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label: "Add Row(s)",
          saveInto: {
            a!save(
              local!rows,
              append(
                local!rows,
                {
                  {
                    id: max(local!rows.id) + 1,
                    name: "row " & max(local!rows.id) + 1
                  },
                  {
                    id: max(local!rows.id) + 2,
                    name: "row " & max(local!rows.id) + 2
                  }
                }
              )
            )
          }
        )
      )
    )

Children