Showing data in a grid

Certified Associate Developer

Hi All, I have a requirment in my Interface that I am displaying the data in a grid through Expression rule . But in that there are some fields like say isA , isB and isC  with 0 and 1 value in database . But now the The condition is that I have to show the Yes , No , N/A in the grid instead of 0 and 1 on some conditions like

1. If isA is 0 in database  then isB and isC should be N/A in the grid and isA will No in the grid

2. If isA is 1 and isB is 0 in the database then isA will be yes , isB will No  and isC is N/A in the Grid

3. If isA is 1 and isB is 1 in the database then isA will be yes , isB will be Yes and isC yes/No based on value in database

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • Hi

    You will be able to achieve your solution in many different ways, please refer to the code below as it can give you some ideas, and than you can improve and adjust for your scenario.

    a!localVariables(
      local!dataFromDb: {
        a!map(scenario: 1, isA: 0, isB: 1, isC: 1, colour: "#3498db"),
        a!map(scenario: 2, isA: 1, isB: 0, isC: 1, colour: "#2ecc71"),
        a!map(scenario: 3, isA: 1, isB: 1, isC: 0, colour: "#2980b9")
      },
      local!selectedData:null,
      local!convertedData: a!refreshVariable(
        value: if(
          isnull(local!selectedData),
          null,
          if(
          index(local!selectedData,"isA",null)=false(),  
          a!update(local!selectedData,{"isA","isB","isC"},{"Yes","N/A","N/A"}),
          if(
            index(local!selectedData,"isB",null)=true(),
            a!update(local!selectedData,{"isA","isB","isC"},{"Yes","Yes",if(index(local!selectedData,"isC",null),"Yes","No")}),
            a!update(local!selectedData,{"isA","isB","isC"},{"Yes","No","N/A"}),
          )
        )
        ),
        refreshOnReferencedVarChange: true()
      ),
      {
        a!columnsLayout(
          alignVertical: "MIDDLE",
          columns: a!forEach(
            items: local!dataFromDb,
            expression: {
              a!columnLayout(
                contents: a!cardLayout(
                  style: fv!item.colour,
                  contents: a!richTextDisplayField(
                    align: "CENTER",
                    value: a!richTextItem(
                      color: "#FFF",
                     text: concat("Scenario: ",fv!item.scenario)
                    )
                  ),
                  link: a!dynamicLink(
                    value: fv!item,
                    saveInto: a!save(local!selectedData,save!value)
                  )
                )
              )
            }
          )
        ),
       a!gridLayout(
         label: "Community Question",
         headerCells: a!forEach(
           items: {"isA","isB","isC"},
           expression:  a!gridLayoutHeaderCell(
             label: fv!item,
             align: "CENTER"
           ),
         ),
         rows: a!gridRowLayout(
          contents: {
           a!textField(
             align: "CENTER",
             readOnly: true(),
             value: index(local!convertedData,"isA",null)
           ),
           a!textField(
             align: "CENTER",
             readOnly: true(),
             value: index(local!convertedData,"isB",null)
           ),
           a!textField(
             align: "CENTER",
             readOnly: true(),
             value: index(local!convertedData,"isC",null)
           )
           }
         )
       
        
       )
      }
      
    )

    I hope that helps,

    Regards,

    Acacio B

  • 0
    Certified Associate Developer
    in reply to Acacio Barrado

    Hi Acacio,

    I have to show the respective yes , no , n/a in respective columns in the grid . Will it work for the same

Reply Children