How to hide columns in an editable grid?

Is this possible? I have an editable grid in which I'm adding rows dynamically. I want to be able to hid one of the columns given a condition. I know I can do it with a paging grid. But the setup for an editable grid is different.

I tried adding "showWhen: false()" to the different parts of it, header, column config and the column data itself but it doesn't actually work. 

My guest is that the issue has to do with the dynamic rows. When I tried to add a new row I get the error message "Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!gridLayout: A grid layout component [label=“”] has an invalid value for “rows”. Every row layout must have the same number of components and it must match the number of header cells. The row at index 1 has 4 component(s). Expected: 3 component(s)."

 

Has anyone done something like this before?

  Discussion posts and replies are publicly visible

Parents
  • Hi Jose H,

    Try below code, may be it's helpful for you.....

    load(
    local!employees: {
    {
    firstName: "abcd",
    lastName: "efgh"
    },
    {
    firstName: "xxxx",
    lastName: "yyyy"
    },

    },
    {
    a!radioButtonField(
    label: "Hide LastName?",
    choiceLabels: {
    "Yes",
    "No"
    },
    choiceValues: {
    "Yes",
    "No"
    },
    value: ri!hideRuleInput,
    saveInto: ri!hideRuleInput
    ),
    a!gridLayout(
    totalCount: count(
    local!employees
    ),
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "First Name"
    ),
    a!gridLayoutHeaderCell(
    label: "Last Name",
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3,
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    rows: a!forEach(
    items: local!employees,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    label: "first name " & fv!index,
    value: fv!item.firstName,
    saveInto: fv!item.firstName,
    required: true
    ),
    a!textField(
    label: "last name " & fv!index,
    value: fv!item.lastName,
    saveInto: fv!item.lastName,
    required: true,
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    id: fv!index
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Employee",
    value: {
    ""
    },
    saveInto: {
    a!save(
    local!employees,
    append(
    local!employees,
    save!value
    )
    )
    }
    )
    )
    }
    )
Reply
  • Hi Jose H,

    Try below code, may be it's helpful for you.....

    load(
    local!employees: {
    {
    firstName: "abcd",
    lastName: "efgh"
    },
    {
    firstName: "xxxx",
    lastName: "yyyy"
    },

    },
    {
    a!radioButtonField(
    label: "Hide LastName?",
    choiceLabels: {
    "Yes",
    "No"
    },
    choiceValues: {
    "Yes",
    "No"
    },
    value: ri!hideRuleInput,
    saveInto: ri!hideRuleInput
    ),
    a!gridLayout(
    totalCount: count(
    local!employees
    ),
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "First Name"
    ),
    a!gridLayoutHeaderCell(
    label: "Last Name",
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3,
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    rows: a!forEach(
    items: local!employees,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    label: "first name " & fv!index,
    value: fv!item.firstName,
    saveInto: fv!item.firstName,
    required: true
    ),
    a!textField(
    label: "last name " & fv!index,
    value: fv!item.lastName,
    saveInto: fv!item.lastName,
    required: true,
    showWhen: if(
    ri!hideRuleInput= "Yes",
    false(),
    true()
    )
    )
    },
    id: fv!index
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Employee",
    value: {
    ""
    },
    saveInto: {
    a!save(
    local!employees,
    append(
    local!employees,
    save!value
    )
    )
    }
    )
    )
    }
    )
Children
No Data