Swap two rows in readable grid

Hi, I have readable grid in which i am using arrow icon, so if I click on that arrow so that row should go up and upper row should come down. I can get all data items from current row, but how I will get data from previous row, So I can apply swapping conditiin

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hi ,

    use the below code it might help.

    What is the use case for this?

    a!localVariables(
      local!data:{
        a!map(
          name:"Test",
          city:"ABC"
        ),
        a!map(
          name:"Test1",
          city:"QWE"
        ),
        a!map(
          name:"Test2",
          city:"DFG"
        ),a!map(
          name:"Test3",
          city:"ZXC"
        ),a!map(
          name:"Test4",
          city:"YUI"
        )
      },
      local!temp,
      local!index,
      a!gridField(
        label: "Employee Data",
        data: local!data,
        columns: {
          a!gridColumn(
            label: "Name",
            value: fv!row.name
          ),
          a!gridColumn(
            label: "Name",
            value: fv!row.city
          ),
          a!gridColumn(
            label: "Name",
            value: a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon:"arrow-up",
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!data, remove(local!data, fv!identifier)),
                      a!save(
                        local!data,
                        insert(local!data, fv!row, fv!identifier - 1)
                      )
                    }
                  )
                )
              }
            )
          ),
          a!gridColumn(
            label: "Name",
            value: a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon:"arrow-down",
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!data, remove(local!data, fv!identifier)),
                      a!save(
                        local!data,
                        insert(local!data, fv!row, fv!identifier + 1)
                      )
                    }
                  )
                )
              }
            )
          )
        }
      )
    )

Reply
  • 0
    Certified Associate Developer

    Hi ,

    use the below code it might help.

    What is the use case for this?

    a!localVariables(
      local!data:{
        a!map(
          name:"Test",
          city:"ABC"
        ),
        a!map(
          name:"Test1",
          city:"QWE"
        ),
        a!map(
          name:"Test2",
          city:"DFG"
        ),a!map(
          name:"Test3",
          city:"ZXC"
        ),a!map(
          name:"Test4",
          city:"YUI"
        )
      },
      local!temp,
      local!index,
      a!gridField(
        label: "Employee Data",
        data: local!data,
        columns: {
          a!gridColumn(
            label: "Name",
            value: fv!row.name
          ),
          a!gridColumn(
            label: "Name",
            value: fv!row.city
          ),
          a!gridColumn(
            label: "Name",
            value: a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon:"arrow-up",
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!data, remove(local!data, fv!identifier)),
                      a!save(
                        local!data,
                        insert(local!data, fv!row, fv!identifier - 1)
                      )
                    }
                  )
                )
              }
            )
          ),
          a!gridColumn(
            label: "Name",
            value: a!richTextDisplayField(
              value: {
                a!richTextIcon(
                  icon:"arrow-down",
                  link: a!dynamicLink(
                    saveInto: {
                      a!save(local!data, remove(local!data, fv!identifier)),
                      a!save(
                        local!data,
                        insert(local!data, fv!row, fv!identifier + 1)
                      )
                    }
                  )
                )
              }
            )
          )
        }
      )
    )

Children
No Data