How to create Editable grid with CDT columns along with non CDT column like some Boolean array.

Certified Senior Developer

Hi,

we have requirement like need to create Editable grid with CDT elements along with one non CDT element. 

Example like after all the CDT columns I want to append another column with Non CDT element like Boolean Array element.

Can you please provide some sample example will help us closing this requirement.

Example

 EMPID EMP Name AGE Eligible
 100  ABC 20

Checkbox

200 XYZ 30 Checkbox

here Eligible column is not part of Employee CDT. its Boolean Array. when he selects the Eligible checkbox we need to store the value in to that Array.

 

Thanks in Advance.

 

 

 

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Just add one text field with readOnly as true as last element of a!gridRowLayout(). For example
    rows:a!forEach(items:CdtElements,
    expression:a!gridRowLayout(
    contents:{
    a!textField(
    label:"Eligible",
    value:arrayBoolean[fv!index],
    readOnly:true
    )
    }
    )
    )

  • Hi!
    To make it "easy" you can add to the row a richtexticon with a link, that stores the index of the row in a variable and changes the icon depending on the values in that variable.
    Here you have a little example:
    load(
    local!aaaa: todatasubset(
    {
    {
    one: "one",
    two: 2
    },
    {
    one: "two",
    two: 1
    }
    }
    ),
    local!gridSelection: a!gridSelection(
    pagingInfo: a!pagingInfo(
    1,
    - 1
    )
    ),
    local!trues,
    {
    a!gridLayout(
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "one"
    ),
    a!gridLayoutHeaderCell(
    label: "two"
    ),
    a!gridLayoutHeaderCell(
    label: "Eligible"
    )
    },
    rows: {
    a!forEach(
    items: local!aaaa.data,
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    value: fv!item.one,
    readOnly: true()
    ),
    a!integerField(
    value: fv!item.two,
    readOnly: true
    ),
    a!richTextDisplayField(
    value: a!richTextIcon(
    icon: if(
    contains(
    ri!valor,
    fv!index
    ),
    "check-square-o",
    "square-o"
    ),
    link: a!dynamicLink(
    saveInto: {
    if(
    contains(
    ri!valor,
    fv!index
    ),
    a!save(
    ri!valor[wherecontains(
    fv!index, ri!valor
    )],
    null
    ),
    a!save(
    ri!valor[fv!index],
    fv!index
    )
    )
    }
    )
    )
    )
    }
    )
    )
    }
    )
    }
    )
    Hope that you find it usefull ;)
  • 0
    Certified Senior Developer
    Unlike gridField, in gridlayout it is not necessary for all elements to be displayed should be part of single cdt.
    In your main rule create a boolean array of same length as that of your CDT. Now pass both these to your grid row rule.

    Ex:
    load(
    local!boolArrayEligble: repeat(count(ri!cdtEmp), true/false ),
    apply(
    rule!GenerateGridRow(
    cdtEmp: ri!cdtEmp,
    boolEligble: local!boolArrayEligble,
    index: _
    ),
    {1,2,3,4,5}
    )
    )

    Hope this helps
  • Hi ramp,

    You can use this code :

    load(
    local!Eligible: repeat(
    count(
    ri!EmployeeCdt
    ),
    null
    ),
    a!gridLayout(
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "Id"
    ),
    a!gridLayoutHeaderCell(
    label: "Name"
    ),
    a!gridLayoutHeaderCell(
    label: "Age"
    ),
    a!gridLayoutHeaderCell(
    label: "Eligible"
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE"
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE"
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE"
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE"
    )
    },
    rows: a!forEach(
    items: if(
    or(
    isnull(
    ri!EmployeeCdt
    ),
    count(
    ri!EmployeeCdt
    ) < 1
    ),
    {},
    1 + enumerate(
    count(
    ri!EmployeeCdt
    )
    )
    ),
    expression: a!gridRowLayout(
    contents: {
    a!textField(
    label: "EMPID",
    labelPosition: "ABOVE",
    value: ri!EmployeeCdt[fv!item].EMPID,
    saveInto: ri!EmployeeCdt[fv!item].EMPID,
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "EMP Name",
    labelPosition: "ABOVE",
    value: ri!EmployeeCdt[fv!item].EMPName,
    saveInto: ri!EmployeeCdt[fv!item].EMPName,
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Age",
    labelPosition: "ABOVE",
    value: ri!EmployeeCdt[fv!item].Age,
    saveInto: ri!EmployeeCdt[fv!item].Age,
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!checkboxField(
    label: "Eligible",
    choiceLabels: {
    "Yes",
    "No"
    },
    choiceValues: {
    "Yes",
    "No"
    },
    value: local!Eligible[fv!item],
    saveInto: local!Eligible[fv!item]
    )
    }
    )
    )
    )
    )

    Hope it will help