How to add Columns to an editable Grid Dynamically?

HI All,

 

Is there any possibility in Appian to add columns in an editable grid dynamically on a click of  link ? 

 

Thanks in Advance.

 

Note: Functionality which I'm looking for needs a dynamic addition of columns?, I'm aware of the option that we can interchange the columns to rows and rows to columns and then add a row, but curious to find out if it is possible to add columns in appian 

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    I don't think it is possible to add columns dynamically as we can't add the respective column in the CDT or data type automatically.
  • Hi adithyay,

     

    I've attached example SAIL code to show you how to dynamically add a column with a link.

     

    load(
      local!data: {
        1,
        2,
        3,
        4,
        5
      },
      {
        a!linkField(
          links: a!dynamicLink(
            label: "Add New Column",
            saveInto: a!save(
              target: local!data,
              value: a!forEach(
                items: local!data,
                expression: append(
                  fv!item,
                  ""
                )
              )
            )
          )
        ),
        a!gridLayout(
          label: "Editable Grid",
          labelPosition: "ABOVE",
          headerCells: {
            a!forEach(
              items: local!data,
              expression: if(
                fv!isFirst,
                a!forEach(
                  items: fv!item,
                  expression: a!gridLayoutHeaderCell(
                    label: "Column " & fv!index
                  )
                ),
                {}
              )
            )
          },
          columnConfigs: {
            a!forEach(
              items: local!data,
              expression: if(
                fv!isFirst,
                a!forEach(
                  items: fv!item,
                  expression: a!gridLayoutColumnConfig(
                    width: "DISTRIBUTE"
                  )
                ),
                {}
              )
            )
          },
          rows: {
            a!forEach(
              items: local!data,
              expression: a!gridRowLayout(
                contents: {
                  a!forEach(
                    items: fv!item,
                    expression: a!textField(
                      label: "Text",
                      labelPosition: "ABOVE",
                      value: fv!item,
                      saveInto: fv!item,
                      refreshAfter: "UNFOCUS",
                      validations: {}
                    )
                  )
                }
              )
            )
          },
          selectionSaveInto: {},
          validations: {},
          shadeAlternateRows: true,
          saveInto: local!data
        )
      }
    )

    I hope this helps you.