Editable grid view with dropdown
I have a grid layout consist of dropdown, If I select a value on the first drop down then if I add new row it will show new drop down on the second drop down I need to hide the value that is selected on the first drop down. Here is my initial code. I just created it but the problem is in choiceLabel it's showing id. The requirements is to show the column "name". I try indexing it but it show an error.
a!localVariables(
local!service: rule!IBM_GetServiceByFilter(
extractData: true,
fetchAll: true,
status: {cons!IBM_SERVICE_STATUS_PENDING_APPROVAL,cons!IBM_SERVICE_STATUS_ACTIVE}
),
local!user: user(loggedInUser(), "firstName") & " " & user(loggedInUser(), "lastName"),
local!now: now(),
{
a!gridLayout(
labelPosition: "ABOVE",
headerCells: {
a!gridLayoutHeaderCell(label: "List of services"),
a!gridLayoutHeaderCell(label: "" )
},
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "ICON")
},
rows: a!forEach(
items: ri!channelService,
expression: a!gridRowLayout(
id: fv!index,
contents: {
a!dropdownField(
label: "Dropdown",
labelPosition: "ABOVE",
placeholder: "--- Select a Service ---",
choiceLabels:
difference(
tointeger(local!service.id),
tointeger(
difference(
ri!channelService.serviceId,
fv!item.serviceId
)
)
),
choiceValues: difference(
tointeger(local!service.id),
tointeger(
difference(
ri!channelService.serviceId,
fv!item.serviceId
)
)
),
value: fv!item.serviceId,
saveInto: fv!item.serviceId,
searchDisplay: "ON",
required: true,
requiredMessage: "Service is required"
),
/*Remove row*/
a!richTextDisplayField(
value: a!richTextIcon(
icon: "close",
altText: "delete " & fv!index,
caption: "Remove",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
a!isNotNullOrEmpty(fv!item.id),
a!save(
ri!deletedChannelService,
append(
ri!deletedChannelService,
a!update(
data: fv!item,
index: "status",
value: cons!IBM_SERVICE_STATUS_FOR_DELETION)
)
),
null
),
a!save(ri!channelService, remove(ri!channelService, save!value))
}
),
linkStyle: "STANDALONE",
showWhen: length(ri!channelService) > 1,
color: "NEGATIVE"
)
)
}
)
),
selectionSaveInto: {},
addRowlink: a!dynamicLink(
label: "Add Service",
value: {
frontChannelId: if(
ri!action = "Update",
ri!frontChannelId,
null
),
serviceId: null,
status: "DRAFT",
createdBy: local!user,
createdDate: local!now,
updatedBy: local!user,
updatedDate: local!now
},
saveInto: {
a!save(
ri!channelService,
append(ri!channelService,save!value)
)
},
showWhen: true
),
validations: {},
shadeAlternateRows: true
)
}
)

