Skip to main content
May 27, 2021
Question

select multiple checkbox in grid and map it to CDT

  • May 27, 2021
  • 2 replies
  • 0 views

Hi guys,

I am working on a requirement like editable grid which contains 2 columns, In first column we are having textfield, In second checkbox.

I need to procide row based on Roles for grid field which includes textfield and checkbox.In checkbox in need to select multiple function

I have 3 nested CDT and
getting the value from role and function cdt,
Need to display these to in Grid and map it to role Function CDT

Here is my input to the ruleInput

{
function:{{functionName:"admin"},{functionName:"view"}},
role:{{roleName:"admin"},{roleName:"view"}},
}

Code:

a!localVariables(

local!getfunctionNames:
a!forEach(items: ri!AppDetails.function, expression: fv!item.functionName),
local!getRoleName:a!forEach(items: ri!AppDetails.role, expression: fv!item.roleName),

local!role,
local!funtion,
local!delete,
{
a!sectionLayout(
contents: {
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
a!richTextItem(
text: "Role function Mapping",
size: "MEDIUM"
)
}
),

},

),
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(label: "Role", align: "LEFT"),
a!gridLayoutHeaderCell(label: "Function", align: "LEFT"),

},
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),

},
rows: a!forEach(
items: local!getRoleName,
expression: a!gridRowLayout(

contents: {
a!textField(
readOnly: true(),
value: local!getRoleName[fv!index],
saveInto:{
ri!roleFunction.role

}

),

a!checkboxField(

choiceLabels: local!getfunctionNames,
choiceValues: local!getfunctionNames,
value:local!funtion,
saveinto:{

ri!roleFunction.function

}


),


}
/*showWhen: local!displayActive=toboolean(fv!item.active)*/

)
)

),

if(ri!readOnly,{},
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Go Back",
size: "LARGE",
value: 3,
saveInto: ri!currentStep

)
},
align: "START",
marginBelow: "NONE"
)
}
),
a!columnLayout(
contents: {
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Continue",
size: "LARGE",
style: "PRIMARY",
value:5,
saveInto: {
ri!currentStep,
},

)
},
align: "END",
marginBelow: "NONE"
)
}
)
}
))})

Please help me .Thanks in advance

    2 replies

    mikes0011
    Brainy
    May 27, 2021

    FYI, for code of this length (or really any length) it's hugely beneficial to post it inside a Code Box ("Insert -- Insert Code" in the little menu where you type text here).  That both preserves indentation as well as keeps it from making a 1-page post into a 5-page post.

    As far as your use case - can you clarify what you want to happen, and what you're seeing instead?  I'm unclear on either of these points from reading your description.

    mathieud0001
    May 27, 2021

    One approach is to save the values in a delimited string. See here for an example: community.appian.com/.../61929