Create dynamic columns for the gridField based on the data.

Hello,

I am new to Appian and have a requirement to create grid columns dynamically based on the data available in the database. I need to generate these columns dynamically according to the available data.

Thank You..!!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    The following code might be helpful:

    = a!localVariables(
      local!CDTFields: split(
        stripwith(
          tostring(
            'type!{urn:com:appian:types:YD}YD_DEMO123'()
          ),
          "=[] "
        ),
        ","
      ),
      local!cdtData: a!queryEntity(
        entity: cons!YD_DT_DEMO123,
        query: a!query(
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      {
        a!gridField(
          data: local!cdtData.data,
          columns: a!forEach(
            items: local!CDTFields,
            expression: a!gridColumn(
              label: fv!item,
              value: index(fv!row, fv!item),
              align: "END"
            )
          )
        )
      }
    )

    You have to replace CDT name in the above code.

Reply
  • 0
    Certified Associate Developer

    The following code might be helpful:

    = a!localVariables(
      local!CDTFields: split(
        stripwith(
          tostring(
            'type!{urn:com:appian:types:YD}YD_DEMO123'()
          ),
          "=[] "
        ),
        ","
      ),
      local!cdtData: a!queryEntity(
        entity: cons!YD_DT_DEMO123,
        query: a!query(
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      {
        a!gridField(
          data: local!cdtData.data,
          columns: a!forEach(
            items: local!CDTFields,
            expression: a!gridColumn(
              label: fv!item,
              value: index(fv!row, fv!item),
              align: "END"
            )
          )
        )
      }
    )

    You have to replace CDT name in the above code.

Children
No Data