3 Separate Grids but the same CDT

Hi, 

I am able to create an editable grid. In order to separate the rows by type, I have created 3 grids on the same interface that are linked to the same CDT. How can I create filters so that the data displayed on each grid will be of a certain type? 

The hard bit then, is when I select "remove row", how can I best manage the index so it deletes the correct row?

I am using a!forEach to create the grid following the Appian recipes. 

Many thanks, 

Eric

  Discussion posts and replies are publicly visible

Parents
  • +2
    Certified Lead Developer

    Hi Eric,

    one possible solution is to use the showWhen parameter to filter your grid. You can delete the correct row by just using fv!index. Here is a solution for one grid:

    load(
      local!data: {
        {
          name: "one",
          grid: 1
        },
        {
          name: "two",
          grid: 2
        },
        {
          name: "three",
          grid: 1
        },
        {
          name: "four",
          grid: 2
         }
      },
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Name"),
          a!gridLayoutHeaderCell(label: "")
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(),
          a!gridLayoutColumnConfig(width: "ICON")
        },
        rows: a!forEach(
          items: local!data,      
          expression: a!gridRowLayout(
            showWhen: tointeger(fv!item.grid) = 1,
            contents: {
              a!textField(
                value: fv!item.name
              ),
              a!imageField(
                images: a!documentImage(
                  document: a!iconIndicator(
                    "REMOVE"
                  ),
                  link: a!dynamicLink(
                    saveInto: local!data,
                    value: remove(local!data, fv!index)
                  )
                )
              )
            }
          )
        )
      )
    )

Reply
  • +2
    Certified Lead Developer

    Hi Eric,

    one possible solution is to use the showWhen parameter to filter your grid. You can delete the correct row by just using fv!index. Here is a solution for one grid:

    load(
      local!data: {
        {
          name: "one",
          grid: 1
        },
        {
          name: "two",
          grid: 2
        },
        {
          name: "three",
          grid: 1
        },
        {
          name: "four",
          grid: 2
         }
      },
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Name"),
          a!gridLayoutHeaderCell(label: "")
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(),
          a!gridLayoutColumnConfig(width: "ICON")
        },
        rows: a!forEach(
          items: local!data,      
          expression: a!gridRowLayout(
            showWhen: tointeger(fv!item.grid) = 1,
            contents: {
              a!textField(
                value: fv!item.name
              ),
              a!imageField(
                images: a!documentImage(
                  document: a!iconIndicator(
                    "REMOVE"
                  ),
                  link: a!dynamicLink(
                    saveInto: local!data,
                    value: remove(local!data, fv!index)
                  )
                )
              )
            }
          )
        )
      )
    )

Children