how to add validation in editable grid if your using multiple updation.

Background:

I have selectable Editable grid where I want to validation each row the value in particular column is unique while updating or addying it in grid.

the updation can be multiple.

Can any one suggest me on that asap,

Parents
  • The easiest way to do this is to use the contains() function. This function will return true if any of the values in a list match the provided value, so you can use it to determine if each column value is unique or not. Here's an example:

    a!localVariables(
      local!data: {},
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Name"),
          a!gridLayoutHeaderCell(label: "Amount"),
        },
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.name,
                saveInto: fv!item.name,
                validations: {
                  if(
                    contains(remove(local!data.name, fv!index), fv!item.name),
                    "This value is a duplicate",
                    null
                  )
                }
              ),
              a!integerField(
                value: fv!item.name,
                saveInto: fv!item.name
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label: "Add Row",
          value: append(local!data, {name: null, amount: null}),
          saveInto: local!data
        )
      )
    )

Reply
  • The easiest way to do this is to use the contains() function. This function will return true if any of the values in a list match the provided value, so you can use it to determine if each column value is unique or not. Here's an example:

    a!localVariables(
      local!data: {},
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Name"),
          a!gridLayoutHeaderCell(label: "Amount"),
        },
        rows: a!forEach(
          items: local!data,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.name,
                saveInto: fv!item.name,
                validations: {
                  if(
                    contains(remove(local!data.name, fv!index), fv!item.name),
                    "This value is a duplicate",
                    null
                  )
                }
              ),
              a!integerField(
                value: fv!item.name,
                saveInto: fv!item.name
              )
            }
          )
        ),
        addRowLink: a!dynamicLink(
          label: "Add Row",
          value: append(local!data, {name: null, amount: null}),
          saveInto: local!data
        )
      )
    )

Children
No Data

 Discussion posts and replies are publicly visible