Skip to main content
kavyan471063
Known Participant
February 4, 2022
Question

Grid field to have a change in variable.

  • February 4, 2022
  • 16 replies
  • 0 views

Hi guys,

I am having a grid where a set of data will be on display. In a column I have used Icon indicator and a dynamic link. When I click it should change from true to false or false to true and the respective icon sholud change in the grid. Any solution for that. I have tried some ways but in the save option of dynamic link I am struck. Thanks in Advance.

Regards,

Kavya

    16 replies

    stefanhelzle0001
    Brainy
    February 4, 2022

    Please post your code, at least the saveInto.

    kavyan471063
    Known Participant
    February 4, 2022

    a!gridImageColumn(
                      label: "Active?",
                      field: "active",
                      data: {
                        a!forEach(
                          items: index(
                            local!data,
                            "active",
                            {}
                          ),
                          expression: if(
                            fv!item = 1,
                            a!documentImage(
                              document: a!iconIndicator(
                                icon: "STATUS_OK"
                              ),
                              caption: "Yes",
                              link: a!dynamicLink(
                                label: "change",
                                value: if(
                                  fv!item = 1,
                                  false,
                                  true
                                ),
                                saveInto: a!save(
                                  ri!change,
                                  if(
                                    fv!item = 1,
                                    false,
                                    true
                                  )
                                )
                              )
                            ),
                            a!documentImage(
                              document: a!iconIndicator(
                                icon: "STATUS_NOTDONE"
                              ),
                              caption: "No",
                              link: a!dynamicLink(
                                label: "change",
                                value: if(
                                  fv!item = 1,
                                  false,
                                  true
                                ),
                                saveInto: a!save(
                                  ri!change,
                                  if(
                                    fv!item = 1,
                                    false,
                                    true
                                  )
                                )
                              )
                            )
                          )
                        )
                      }/*index(local!data,"active",{})*/
                      
                    )

    ri!change is a boolean variable I used for checking purpose. It was supposed to replace the value in local!data .

    Regards,

    Kavya

    stefanhelzle0001
    Brainy
    February 4, 2022

    I assume ri!change is a multiple. Then you need to address that specific value in that list. Use the square bracket notation. And there is no need to compare a boolean to "1".

    It might be necessary to pre-populate ri!change with as many items as you have in your grid.

    value: not(ri!change[fv!index]),
    saveInto: ri!change[fv!index],

    agamb0001
    February 4, 2022

    Hi Kavya, 

    You can try an approach like this

    If you need, you can also save into ri!change according to its structure / type

    a!localVariables(
      local!paging: a!pagingInfo(1, 10),
      local!data: { { active: true() }, { active: false() } },
      a!gridField_19r1(
        /*use a!gridField() if you are on 19.1 version*/
        value: local!paging,
        totalCount: count(local!data),
        columns: {
          a!gridImageColumn(
            label: "Active?",
            field: "active",
            data: a!forEach(
              items: index(local!data, "active", {}),
              expression: a!localVariables(
                local!change: toboolean(fv!item),
                a!documentImage(
                  document: a!iconIndicator(
                    icon: if(
                      local!change,
                      "STATUS_OK",
                      "STATUS_NOTDONE"
                    )
                  ),
                  caption: if(local!change, "Yes", "No"),
                  link: a!dynamicLink(
                    label: "change",
                    value: not(local!change),
                    saveInto: { local!change }
                  )
                )
              )
            )
          )
        }
      )
    )

    kavyan471063
    Known Participant
    February 11, 2022

    Thank you Its working.