How to have gridLayoutHeaderCell in gridlayout ? How to create columns dynamically in a grid ?

I am trying below code. Here, expression rule GPO_questionDetails returns a list for a given number.

a!gridLayout(
label:"program",
headerCells: {
a!forEach(
items: {"230108","230109","230110"},
expression:{
a!localVariables(
local!list: rule!GPO_questionDetails(questionID: fv!item),
a!gridLayoutHeaderCell(label: local!list.label)
)}
),
if(not(rule!APN_isTrue(ri!isReadOnly)),a!gridLayoutHeaderCell(label: ""),{})
},

Error: Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!gridLayout [line 35]: A grid component [label="program"] has an invalid value for "headerCells". "headerCells" can only be of type GridLayoutHeaderCell. Received List of GridHeaderCell at index 1.

Can some one help me to fix this ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Avoid the {} in your a!forEach expression parameter.   you are doing a "a!forEach(items:{1,2,3}, expression:{...})
    just do a  "a!forEach(items:{1,2,3}, expression:...)  then it should be fine.

    a!gridLayout(
        label:"program",
        headerCells: {
            a!forEach(
                items: {"230108","230109","230110"},
                expression:  a!localVariables(
                        local!list: rule!GPO_questionDetails(questionID: fv!item),
                        a!gridLayoutHeaderCell(label: local!list.label)
                )
                
            ),
            if(
                not(rule!APN_isTrue(ri!isReadOnly)),
                a!gridLayoutHeaderCell(label: ""),
                {}
            )
        }
    ),


Reply
  • 0
    Certified Senior Developer

    Avoid the {} in your a!forEach expression parameter.   you are doing a "a!forEach(items:{1,2,3}, expression:{...})
    just do a  "a!forEach(items:{1,2,3}, expression:...)  then it should be fine.

    a!gridLayout(
        label:"program",
        headerCells: {
            a!forEach(
                items: {"230108","230109","230110"},
                expression:  a!localVariables(
                        local!list: rule!GPO_questionDetails(questionID: fv!item),
                        a!gridLayoutHeaderCell(label: local!list.label)
                )
                
            ),
            if(
                not(rule!APN_isTrue(ri!isReadOnly)),
                a!gridLayoutHeaderCell(label: ""),
                {}
            )
        }
    ),


Children