GridField With Dynamic Links on a multiple fields

HI, 

I have struck at a point...

I am working grid field, I have provided links for two columns in the grid field, By default column 1 link was enabled when I clicked and submitted data column 1 link had to be disabled. and the column 2  link has to be enabled After submission of column 2 data, the column 2 link also has to be disabled...

Help me with a sample code

 

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    Hi , you can use the saevInto in dynamicLinik and on a change of variable in the dynamic link you can further use condition in the disable field of the gridField.
    You can be specific with your question by providing a code you have written to achieve what you want.

  • 0
    Certified Lead Developer

    This should be able to start you off.

    a!localVariables(
      local!data: {
        a!map(
          id: 1,
          name: a!map(value: "John Smith", isSubmitted: false),
          email: a!map(
            value: "johnsmith@email.com",
            isSubmitted: false
          )
        ),
        a!map(
          id: 2,
          name: a!map(value: "Jane Pittman", isSubmitted: false),
          email: a!map(
            value: "janepittman@email.com",
            isSubmitted: false
          )
        ),
        a!map(
          id: 3,
          name: a!map(
            value: "Mike Davenport",
            isSubmitted: false
          ),
          email: a!map(
            value: "mikedavenport@email.com",
            isSubmitted: false
          )
        )
      },
      {
        a!gridField(
          label: "Read-only Grid",
          labelPosition: "ABOVE",
          data: local!data,
          columns: {
            a!gridColumn(label: "ID", value: fv!row.id),
            a!gridColumn(
              label: "Name",
              value: a!localVariables(
                local!fieldName: "name",
                local!item: index(fv!row, local!fieldName, null),
                a!richTextDisplayField(
                  value: a!richTextItem(
                    text: local!item.value,
                    link: if(
                      local!item.isSubmitted,
                      null,
                      a!dynamicLink(
                        saveInto: {
                          a!save(
                            local!data,
                            a!update(
                              local!data,
                              fv!identifier,
                              a!update(
                                fv!row,
                                local!fieldName,
                                a!update(local!item, "isSubmitted", true)
                              )
                            )
                          )
                        }
                      )
                    )
                  )
                )
              )
            ),
            a!gridColumn(
              label: "Email",
              value: a!localVariables(
                local!fieldName: "email",
                local!item: index(fv!row, local!fieldName, null),
                a!richTextDisplayField(
                  value: a!richTextItem(
                    text: local!item.value,
                    link: if(
                      or(
                        local!item.isSubmitted,
                        not(fv!row.name.isSubmitted)
                      ),
                      null,
                      a!dynamicLink(
                        saveInto: {
                          a!save(
                            local!data,
                            a!update(
                              local!data,
                              fv!identifier,
                              a!update(
                                fv!row,
                                local!fieldName,
                                a!update(local!item, "isSubmitted", true)
                              )
                            )
                          )
                        }
                      )
                    )
                  )
                )
              )
            )
          },
          validations: {}
        )
      }
    )