Adding Multiple Editable Grids in an Interface

Certified Senior Developer

Requiremnt: When user clicks on "Add Grid" then an editable grid should be added and when the user clicks on "Add Row" then a row should be added to the respective grid

a!localVariables(
  local!count:1,
  local!data:a!forEach(items: enumerate(local!count)+1,
    expression: {{a!map(text1:"",text2:"")}}),
  a!sectionLayout(
    contents: {
      a!forEach(
        items: enumerate(local!count)+1,
        expression: a!gridLayout(
          label: "Grid"&fv!index,
          headerCells: {
            a!gridLayoutHeaderCell(
              label: "H1"
            ),
            a!gridLayoutHeaderCell(
              label: "h2"
            )
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(

            ),
            a!gridLayoutColumnConfig()
          },
          rows: a!forEach(
            items: local!data[fv!index],
            expression: a!gridRowLayout(
              contents: {
              a!textField(
                label: fv!item,
                value: "",
                saveInto: {
                  a!save(local!data[fv!index]["text1"],save!value)
                }
              ),
              a!textField(
                label: fv!item,
                value: "",
                saveInto: {
                  a!save(local!data[fv!index]["text2"],save!value)
                }
              )
            }
            )
          ),
          
          
    
          addRowLink: a!dynamicLink(
            label: "Add row",
            value: a!map(text1:"",text2:""),
            saveInto: {
              a!save(local!data[fv!index],append(local!data[fv!index],save!value))
            }
          )
        )
      ),
      a!richTextDisplayField(
        value: a!richTextItem(
          text: "Add Grid",
          link: a!dynamicLink(
            saveInto: {
              a!save(local!count,local!count+1)
            }
          )
        )
      )
      
    }
  )
)

The problem I am facing is that when I click on "Add Grid" it gets added but when I click on "Add Row" then it gets added to the local!data but it's not reflecting in the interface

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Could not get clearly what you are asking. 

    But from seeing the code, I would suggest

    1)Since you are using a Common local!data to store from All grids, add a new label name GridNumber in the map and store the grid number when a row is added. By doing this you can index and show the rows for corresponding grid

    2)In textfields, VALUE parameter is empty. Please map with the variables

Reply
  • 0
    Certified Senior Developer

    Could not get clearly what you are asking. 

    But from seeing the code, I would suggest

    1)Since you are using a Common local!data to store from All grids, add a new label name GridNumber in the map and store the grid number when a row is added. By doing this you can index and show the rows for corresponding grid

    2)In textfields, VALUE parameter is empty. Please map with the variables

Children